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 <[email protected]>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed May 20, 2024
1 parent 3d073cb commit a192158
Show file tree
Hide file tree
Showing 41 changed files with 4,176 additions and 205 deletions.
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# Image URL to use all building/pushing image targets
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 @@ -81,10 +85,26 @@ run: manifests generate fmt vet ## Run a controller from your host.
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .

.PHONY: docker-build-sidecar
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}

.PHONY: docker-push-sidecar
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

RELEASE_DIR ?= out
Expand All @@ -108,13 +128,23 @@ endif
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: install-certs
install-certs: manifests kustomize ## Install certs
$(KUSTOMIZE) build config/certmanager | kubectl apply -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: uninstall-certs
uninstall-certs: manifests kustomize ## Uninstall certs
$(KUSTOMIZE) build config/certmanager | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
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{})
}
51 changes: 51 additions & 0 deletions api/v1alpha1/nodeconfigprocess_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NodeConfigSpec defines the desired state of NodeConfig.
type NodeConfigProcessSpec struct {
State string `json:"state"`
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:shortName=ncp,scope=Cluster
//+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.spec.state`

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

Spec NodeConfigProcessSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&NodeConfigProcess{}, &NodeConfigProcessList{})
}
181 changes: 181 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 a192158

Please sign in to comment.