From a8652389ae4de98ca580198594f5a3198080b6de Mon Sep 17 00:00:00 2001 From: Jim Fitzpatrick Date: Mon, 8 Jul 2024 14:32:58 +0100 Subject: [PATCH 1/2] Update uninstall - create and delete authorino-operator namespace (requied by make install-authorino) - add make uninstall-authorino - add make uninstall-cert-manager - update make uninstall --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 34518b22..0f51e883 100644 --- a/Makefile +++ b/Makefile @@ -211,6 +211,7 @@ install: manifests kustomize install-authorino ## Install CRDs into the K8s clus uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. kubectl delete -f $(OPERATOR_MANIFESTS) + $(MAKE) uninstall-authorino deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. cd config/manager && $(KUSTOMIZE) edit set image controller=${OPERATOR_IMAGE} @@ -222,12 +223,21 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi $(KUSTOMIZE) build config/default | kubectl delete -f - install-authorino: install-cert-manager ## install RBAC and CRD for authorino + kubectl create namespace authorino-operator $(KUSTOMIZE) build config/authorino | kubectl apply -f - +uninstall-authorino: ## uninstall RBAC and CRD for authorino + $(KUSTOMIZE) build config/authorino | kubectl delete -f - + kubectl delete namespace authorino-operator + $(MAKE) uninstall-cert-manager + install-cert-manager: ## install the cert manager need for the web hooks kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v${CERT_MANAGER_VERSION}/cert-manager.yaml kubectl -n cert-manager wait --timeout=300s --for=condition=Available deployments --all +uninstall-cert-manager: ## uninstall the cert manager need for the web hooks + kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v${CERT_MANAGER_VERSION}/cert-manager.yaml + # go-get-tool will 'go install' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) define go-get-tool From f5e773c829f3a0156520e7450995c9790a582991 Mon Sep 17 00:00:00 2001 From: Jim Fitzpatrick Date: Mon, 22 Jul 2024 11:10:57 +0100 Subject: [PATCH 2/2] Refactor deployment commands to have `` and `un` - `` = runs deps + action itself; safe to run if deps already present - `un` = undo the action only --- Makefile | 30 ++++++++++++++++++------------ README.md | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 0f51e883..0e70390e 100644 --- a/Makefile +++ b/Makefile @@ -206,12 +206,9 @@ docker-push: ## Push docker image with the manager. ##@ Deployment -install: manifests kustomize install-authorino ## Install CRDs into the K8s cluster specified in ~/.kube/config. - kubectl apply -f $(OPERATOR_MANIFESTS) +install: install-authorino install-operator ## Install CRDs into the K8s cluster specified in ~/.kube/config. -uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. - kubectl delete -f $(OPERATOR_MANIFESTS) - $(MAKE) uninstall-authorino +uninstall: uninstall-operator uninstall-authorino ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. cd config/manager && $(KUSTOMIZE) edit set image controller=${OPERATOR_IMAGE} @@ -220,23 +217,32 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/default | kubectl delete -f - + $(KUSTOMIZE) build config/default | kubectl delete -f - --ignore-not-found + +install-operator: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. + kubectl apply -f $(OPERATOR_MANIFESTS) -install-authorino: install-cert-manager ## install RBAC and CRD for authorino - kubectl create namespace authorino-operator +uninstall-operator: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. + kubectl delete -f $(OPERATOR_MANIFESTS) --ignore-not-found + +install-authorino: create-namespace install-cert-manager ## install RBAC and CRD for authorino $(KUSTOMIZE) build config/authorino | kubectl apply -f - uninstall-authorino: ## uninstall RBAC and CRD for authorino - $(KUSTOMIZE) build config/authorino | kubectl delete -f - - kubectl delete namespace authorino-operator - $(MAKE) uninstall-cert-manager + $(KUSTOMIZE) build config/authorino | kubectl delete -f - --ignore-not-found install-cert-manager: ## install the cert manager need for the web hooks kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v${CERT_MANAGER_VERSION}/cert-manager.yaml kubectl -n cert-manager wait --timeout=300s --for=condition=Available deployments --all uninstall-cert-manager: ## uninstall the cert manager need for the web hooks - kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v${CERT_MANAGER_VERSION}/cert-manager.yaml + kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v${CERT_MANAGER_VERSION}/cert-manager.yaml --ignore-not-found + +create-namespace: + kubectl create namespace authorino-operator --dry-run=client -o yaml | kubectl apply -f - ## handle namespace already existing. + +delete-namespace: + kubectl delete namespace authorino-operator --ignore-not-found # go-get-tool will 'go install' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/README.md b/README.md index b5995311..4d76c605 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,13 @@ The Operator can be installed by applying the manifests to the Kubernetes cluste ### Applying the manifests to the cluster -1. Create the namespace for the Operator - -```sh -kubectl create namespace authorino-operator -``` - -2. Install the Operator manifests +1. Install the Operator manifests ```sh make install ``` -3. Deploy the Operator +2. Deploy the Operator ```sh make deploy @@ -278,3 +272,30 @@ spec: path: keycloak.crt defaultMode: 420 ``` +## Removal + +### Removing the operator installed via manifests + +1. Undeploy the Operator + +```sh +make undeploy +``` + +2. Remove the Operator manifests + +```sh +make uninstall +``` + +#### Remove dependencies (Optional) + +1. Remove operator namespace +```sh +make delete-namespace +``` + +2. Uninstall cert manager +```sh +make uninstall-cert-manager +```