From afe85b81227142476b8cddb4339960c29ee734c9 Mon Sep 17 00:00:00 2001 From: Varsha Prasad Narsing Date: Wed, 8 Feb 2023 16:46:34 -0500 Subject: [PATCH 1/2] Add targets to Makefile This commit adds two additional Makefile targets to Makefile: - Separate targets to install and uninstall - Rukpak and cert-mgr. - cleanup: Since operator-controller is the single point of entry and `make run` installs Rukpak and Cert-manager, it would be good to have a target that cleans up the cluster of controller and all its dependencies. - run-local: To be able to run the controller locally, it is useful for developments so that we need not always have to build image to test operator. Signed-off-by: Varsha Prasad Narsing --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 69f3a22bf..a091d247f 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,10 @@ build: manifests generate fmt vet ## Build manager binary. .PHONY: run run: docker-build kind-cluster kind-load cert-mgr rukpak install deploy wait ## Build the operator-controller then deploy it into a new kind cluster. +.PHONY: run-local +run-local: manifests generate fmt vet ## Run a controller from your host. Make sure that necessary CRDs are installed in the cluster. + go run ./main.go + .PHONY: wait wait: kubectl wait --for=condition=Available --namespace=$(OPERATOR_CONTROLLER_NAMESPACE) deployment/operator-controller-controller-manager --timeout=$(WAIT_TIMEOUT) @@ -166,6 +170,12 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in 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 - +# cleans up all the operator resources and their dependents like cert-manager and rukpak +.PHONY: cleanup +cleanup: undeploy uninstall + kubectl delete --ignore-not-found=$(ignore-not-found) -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml + kubectl delete --ignore-not-found=$(ignore-not-found) -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml + ##@ Build Dependencies ## Location to install dependencies to From 5918787469f6b795287ebe81a4c9876d732909dc Mon Sep 17 00:00:00 2001 From: Varsha Prasad Narsing Date: Tue, 28 Feb 2023 19:30:36 -0500 Subject: [PATCH 2/2] address review comments Signed-off-by: Varsha Prasad Narsing --- Makefile | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a091d247f..077c60052 100644 --- a/Makefile +++ b/Makefile @@ -97,8 +97,11 @@ kind-cluster-cleanup: kind ## Delete the kind cluster build: manifests generate fmt vet ## Build manager binary. go build -o bin/manager main.go +.PHONY: run-image +run-image: docker-build kind-load install-cert-mgr install-rukpak install deploy wait ## Build the operator-controller then deploy it into an existing kind cluster. + .PHONY: run -run: docker-build kind-cluster kind-load cert-mgr rukpak install deploy wait ## Build the operator-controller then deploy it into a new kind cluster. +run: kind-cluster run-image ## Build the operator-controller then deploy it into a new kind cluster. .PHONY: run-local run-local: manifests generate fmt vet ## Run a controller from your host. Make sure that necessary CRDs are installed in the cluster. @@ -143,16 +146,24 @@ ifndef ignore-not-found endif ## TODO dfranz: replace cert-mgr and rukpak targets with our chosen method of distribution when available -.PHONY: cert-mgr -cert-mgr: ## Install cert-manager +.PHONY: install-cert-mgr +install-cert-mgr: ## Install cert-manager kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=$(WAIT_TIMEOUT) -.PHONY: rukpak -rukpak: ## Install rukpak +.PHONY: uninstall-cert-mgr +uninstall-cert-mgr: ## Install cert-manager + kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml + +.PHONY: install-rukpak +install-rukpak: ## Install rukpak kubectl apply -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml kubectl wait --for=condition=Available --namespace=rukpak-system deployment/core --timeout=$(WAIT_TIMEOUT) +.PHONY: uninstall-rukpak +uninstall-rukpak: ## Install rukpak + kubectl delete -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml + .PHONY: install install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | kubectl apply -f - @@ -172,9 +183,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi # cleans up all the operator resources and their dependents like cert-manager and rukpak .PHONY: cleanup -cleanup: undeploy uninstall - kubectl delete --ignore-not-found=$(ignore-not-found) -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml - kubectl delete --ignore-not-found=$(ignore-not-found) -f https://github.com/operator-framework/rukpak/releases/latest/download/rukpak.yaml +cleanup: undeploy uninstall uninstall-rukpak uninstall-cert-mgr ##@ Build Dependencies