From ab08c8ddccf65af7ba5fba66002a0ba11077a32a Mon Sep 17 00:00:00 2001 From: Or Mergi Date: Mon, 4 Mar 2024 13:39:29 +0200 Subject: [PATCH 1/3] kustomize: Remove configurations leftovers from config/crd Since config/crd/kustomizeconfig.yaml not exist it should be removed from config/crd/kustomization.yaml manifest. Without this change 'make manifests' fails. Signed-off-by: Or Mergi --- config/crd/kustomization.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index c3ad78e..9a858b3 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -4,7 +4,3 @@ resources: - bases/self.service.ovn.org_overlaynetworks.yaml #+kubebuilder:scaffold:crdkustomizeresource - -# the following config is for teaching kustomize how to do kustomization for CRDs. -configurations: -- kustomizeconfig.yaml From d984e250701fe9118c83edd693bad620b1d6cdd0 Mon Sep 17 00:00:00 2001 From: Or Mergi Date: Mon, 4 Mar 2024 17:32:15 +0200 Subject: [PATCH 2/3] makefile: Add cluster-sync target Cluster sync build the controller and deploy it to the local cluster enabling faster iterations. Introduce 'kind-push' target, it enables pushing the controller image to cluster nodes container runtime local registry using KinD. cluster-sync flow: - Remove the installed CRDs, Deployment and all related object (namesapce, sa, rbac, etc..) - Generate manifest (CRD, RBAC, etc..). - Generates code (DeepCopy, etc..). - go fmt, go vet - Build controller the image. - Push the image to cluster nodes container runtime local registry (using kind). - Deploy the controller CRDs. - Generate manifests (Namespace, SA, Deployment, etc.., using Kustomize) - Deploy controller and all related objects. The default container image tag, represented by IMG, is changed as follows to make kind load work as expected: 'localhost/overlay-network-controller:devel' Add 'kustomize' target as a prerequisite of 'undelpoy' target to avoid failures when Kustomize is not installed. Signed-off-by: Or Mergi --- Makefile | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1b0593d..9bcb827 100644 --- a/Makefile +++ b/Makefile @@ -46,8 +46,12 @@ ifeq ($(USE_IMAGE_DIGESTS), true) BUNDLE_GEN_FLAGS += --use-image-digests endif +IMAGE_REGISTRY ?= localhost +IMAGE_NAME ?= overlay-network-controller +IMAGE_TAG ?= devel # Image URL to use all building/pushing image targets -IMG ?= controller:latest +IMG ?= "${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" + # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.25.0 @@ -145,17 +149,13 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla ##@ Deployment -ifndef ignore-not-found - ignore-not-found = false -endif - .PHONY: install install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | 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 - + $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=true -f - .PHONY: deploy deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. @@ -163,8 +163,8 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in $(KUSTOMIZE) build config/default | kubectl apply -f - .PHONY: undeploy -undeploy: ## Undeploy controller 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/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - +undeploy: kustomize ## Undeploy controller 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/default | kubectl delete --ignore-not-found=true -f - ##@ Build Dependencies @@ -261,3 +261,14 @@ cluster-up: .PHONY: cluster-down cluster-down: ./automation/cluster.sh --down + +KIND_BIN ?= kind +CLUSTER_NAME ?= ovn +IMAGE_TAR = "./bin/img.tar" +.PHONY: kind-push +kind-push: + docker save ${IMG} -o ${IMAGE_TAR} + $(KIND_BIN) load image-archive --name=${CLUSTER_NAME} ${IMAGE_TAR} + +.PHONY: cluster-sync +cluster-sync: undeploy uninstall manifests generate fmt vet docker-build kind-push install deploy From 88afbd6a9bcf1612694fc9fb7371b1afc50e8617 Mon Sep 17 00:00:00 2001 From: Or Mergi Date: Mon, 4 Mar 2024 22:12:21 +0200 Subject: [PATCH 3/3] kustomize: Set controller image name This commit change introduced by 'make deploy'. It replaces the default image name ("controller") with the image name spesified in Makefile by $IMG. Signed-off-by: Or Mergi --- config/manager/kustomization.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 5c5f0b8..64f3cde 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization resources: - manager.yaml +images: +- name: controller + newName: localhost/overlay-network-controller + newTag: devel