Skip to content

Commit

Permalink
Merge pull request #8 from ormergi/makefile-cluster-sync
Browse files Browse the repository at this point in the history
Add Makefile cluster sync target
  • Loading branch information
AlonaKaplan authored Mar 5, 2024
2 parents ac4dec4 + 88afbd6 commit fc38133
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -145,26 +149,22 @@ 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.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(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

Expand Down Expand Up @@ -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
4 changes: 0 additions & 4 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fc38133

Please sign in to comment.