From db51d23f0c8ca58c4f914b7cc5c7de705aa51744 Mon Sep 17 00:00:00 2001 From: Chandan Kumar Date: Fri, 15 Nov 2024 17:46:35 +0530 Subject: [PATCH] Add watcher target to deploy operator via olm This pr adds two targets: * `make watcher`: It generates olm.yaml file and installs the watcher-operator using oc. * `make watcher_cleanup`: It generates the olm.yaml file and undeploy the watcher-operator using oc. It also provides $CATALOG_IMAGE var to pass custom watcher-operator index image. Jira: https://issues.redhat.com/browse/OSPRH-11419 Signed-off-by: Chandan Kumar --- .gitignore | 3 +++ Makefile | 16 ++++++++++++++++ README.md | 20 ++++++++++++++++++++ ci/olm.sh | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 ci/olm.sh diff --git a/.gitignore b/.gitignore index 4740b5b..955f948 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ CI_TOOLS_REPO *.swp *.swo *~ + +# CI generated files +ci/olm.yaml diff --git a/Makefile b/Makefile index b59d8bd..300cdd2 100644 --- a/Makefile +++ b/Makefile @@ -371,3 +371,19 @@ update-watcher-csv: if [ "$(has_webhooks)" != "null" ]; then \ oc patch -n $(OPERATOR_NAMESPACE) $(csv) --type json -p='[{"op": "remove", "path": "/spec/webhookdefinitions"}]'; \ fi + +CATALOG_IMAGE ?= quay.io/openstack-k8s-operators/watcher-operator-index:latest + +.PHONY: watcher +watcher: export CATALOG_IMG=${CATALOG_IMAGE} +watcher: ## Deploying watcher operator via olm + bash ci/olm.sh + oc apply -f ci/olm.yaml + $(eval csvname=$(shell oc get csv -n openstack-operators -o jsonpath='{range .items[*]}{@.metadata.name}{"\n"}{end}' | grep -E "^watcher-operator\.v")) + timeout 30 bash -c 'until [ "$(shell oc get -n openstack-operators csv/$(csvname) -o jsonpath='{.status.phase}')" == "Succeeded" ]; do sleep 5; done' + +.PHONY: watcher_cleanup +watcher_cleanup: export CATALOG_IMG=${CATALOG_IMAGE} +watcher_cleanup: ## Cleaning watcher operator via olm + bash ci/olm.sh + oc delete -f ci/olm.yaml diff --git a/README.md b/README.md index 3e9773d..bf0a657 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,26 @@ make uninstall make undeploy ``` +### To Deploy via OLM + +**Deploy watcher-operator via olm + +```sh +make watcher +``` + +**Deply watcher-operator via olm with different catalog image + +``` +make watcher CATALOG_IMAGE= +``` + +**Uninstall watcher-operator + +```sh +make watcher_cleanup +``` + ## Project Distribution Following are the steps to build the installer and distribute this project to users. diff --git a/ci/olm.sh b/ci/olm.sh new file mode 100644 index 0000000..554dd04 --- /dev/null +++ b/ci/olm.sh @@ -0,0 +1,36 @@ +cat <ci/olm.yaml +--- +apiVersion: v1 +kind: Namespace +metadata: + name: openstack-operators + labels: + pod-security.kubernetes.io/enforce: privileged + security.openshift.io/scc.podSecurityLabelSync: "false" +--- +apiVersion: operators.coreos.com/v1alpha1 +kind: CatalogSource +metadata: + name: watcher-operator-index + namespace: openstack-operators +spec: + image: ${CATALOG_IMG} + sourceType: grpc +--- +apiVersion: operators.coreos.com/v1 +kind: OperatorGroup +metadata: + name: openstack + namespace: openstack-operators +--- +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: watcher-operator + namespace: openstack-operators +spec: + name: watcher-operator + channel: alpha + source: watcher-operator-index + sourceNamespace: openstack-operators +EOF