Skip to content

Commit

Permalink
Added support for gradual rollout
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed Jun 12, 2024
1 parent 9de1c88 commit 6c8cec3
Show file tree
Hide file tree
Showing 41 changed files with 3,872 additions and 629 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
IMG ?= ghcr.io/telekom/das-schiff-network-operator:latest
# Sidecar image URL to use all building/pushing image targets
SIDECAR_IMG ?= ghcr.io/telekom/frr-exporter:latest
# Sidecar image URL to use all building/pushing image targets
CONFIGURATOR_IMG ?= ghcr.io/telekom/configurator:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.25

Expand Down Expand Up @@ -87,6 +89,10 @@ docker-build: test ## Build docker image with the manager.
docker-build-sidecar: test ## Build docker image with the manager.
docker build -t ${SIDECAR_IMG} -f frr-exporter.Dockerfile .

.PHONY: docker-build-configurator
docker-build-configurator: test ## Build docker image with the manager.
docker build -t ${CONFIGURATOR_IMG} -f configurator.Dockerfile .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
Expand All @@ -95,6 +101,9 @@ docker-push: ## Push docker image with the manager.
docker-push-sidecar: ## Push docker image with the manager.
docker push ${SIDECAR_IMG}

.PHONY: docker-push-configurator
docker-push-configurator: ## Push docker image with the manager.
docker push ${CONFIGURATOR_IMG}

##@ Release

Expand Down Expand Up @@ -135,6 +144,7 @@ uninstall-certs: manifests kustomize ## Uninstall certs
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/manager && $(KUSTOMIZE) edit set image frr-exporter=${SIDECAR_IMG}
cd config/configurator && $(KUSTOMIZE) edit set image configurator=${CONFIGURATOR_IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
Expand Down
92 changes: 92 additions & 0 deletions api/v1alpha1/nodeconfig_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"reflect"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NodeConfigSpec defines the desired state of NodeConfig.
type NodeConfigSpec struct {
Layer2 []Layer2NetworkConfigurationSpec `json:"layer2"`
Vrf []VRFRouteConfigurationSpec `json:"vrf"`
RoutingTable []RoutingTableSpec `json:"routingTable"`
}

// NodeConfigStatus defines the observed state of NodeConfig.
type NodeConfigStatus struct {
ConfigStatus string `json:"configStatus"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=nc,scope=Cluster
//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.configStatus`

// NodeConfig is the Schema for the node configuration.
type NodeConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NodeConfigSpec `json:"spec,omitempty"`
Status NodeConfigStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// NodeConfigList contains a list of NodeConfig.
type NodeConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NodeConfig `json:"items"`
}

func (nc *NodeConfig) IsEqual(c *NodeConfig) bool {
return reflect.DeepEqual(nc.Spec.Layer2, c.Spec.Layer2) && reflect.DeepEqual(nc.Spec.Vrf, c.Spec.Vrf) && reflect.DeepEqual(nc.Spec.RoutingTable, c.Spec.RoutingTable)
}

func NewEmptyConfig(name string) *NodeConfig {
return &NodeConfig{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: NodeConfigSpec{
Vrf: []VRFRouteConfigurationSpec{},
Layer2: []Layer2NetworkConfigurationSpec{},
RoutingTable: []RoutingTableSpec{},
},
Status: NodeConfigStatus{
ConfigStatus: "",
},
}
}

func CopyNodeConfig(src, dst *NodeConfig, name string) {
dst.Spec.Layer2 = make([]Layer2NetworkConfigurationSpec, len(src.Spec.Layer2))
dst.Spec.Vrf = make([]VRFRouteConfigurationSpec, len(src.Spec.Vrf))
dst.Spec.RoutingTable = make([]RoutingTableSpec, len(src.Spec.RoutingTable))
copy(dst.Spec.Layer2, src.Spec.Layer2)
copy(dst.Spec.Vrf, src.Spec.Vrf)
copy(dst.Spec.RoutingTable, src.Spec.RoutingTable)
dst.OwnerReferences = make([]metav1.OwnerReference, len(src.OwnerReferences))
copy(dst.OwnerReferences, src.OwnerReferences)
dst.Name = name
}

func init() {
SchemeBuilder.Register(&NodeConfig{}, &NodeConfigList{})
}
108 changes: 108 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6c8cec3

Please sign in to comment.