Skip to content

Commit

Permalink
makefile: Add cluster-sync target
Browse files Browse the repository at this point in the history
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
- Deploy the controller CRDs.
- Build controller the image.
- Push the image to cluster nodes container runtime local registry (using KinD).
- 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:
  'quay.io/omergi/overlay-network-controller:devel'

Signed-off-by: Or Mergi <[email protected]>
  • Loading branch information
ormergi committed Mar 4, 2024
1 parent 5a2b32d commit 790322b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif

IMAGE_REGISTRY ?= quay.io
IMAGE_ORG ?= omergi
IMAGE_NAME ?= overlay-network-controller
IMAGE_TAG ?= devel
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMG ?= "${IMAGE_REGISTRY}/${IMAGE_ORG}/${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

Expand Down Expand Up @@ -145,17 +150,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.
Expand All @@ -164,7 +165,7 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in

.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 -
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=true -f -

##@ Build Dependencies

Expand Down Expand Up @@ -261,3 +262,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: undeploy uninstall test install docker-build kind-push deploy

0 comments on commit 790322b

Please sign in to comment.