Skip to content

Commit

Permalink
Add watcher target to deploy operator via olm
Browse files Browse the repository at this point in the history
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.
* `make watcher_deploy`: To deploy the watcher service
* `make watcher_deploy_cleanup`: To undeploy the watcher service

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 <[email protected]>
  • Loading branch information
raukadah committed Nov 19, 2024
1 parent 953b0a8 commit 95db9af
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ CI_TOOLS_REPO
*.swp
*.swo
*~

# CI generated files
ci/olm.yaml
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,26 @@ 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: ## Install watcher operator via olm
bash ci/olm.sh
oc apply -f ci/olm.yaml
timeout 300s bash -c "while ! (oc get csv -n openstack-operators -l operators.coreos.com/watcher-operator.openstack-operators -o jsonpath='{.items[*].status.phase}' | grep Succeeded); do sleep 1; done"

.PHONY: watcher_deploy
watcher_deploy: ## Deploy watcher service
oc apply -f config/samples/watcher_v1beta1_watcher.yaml

.PHONY: watcher_deploy_cleanup
watcher_deploy_cleanup: ## Undeploy watcher service
oc delete -f config/samples/watcher_v1beta1_watcher.yaml

.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
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,42 @@ 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

```sh
make watcher CATALOG_IMAGE=<catalog image url with tag>
```

#### To Deploy watcher service

**Deploy watcher service

```sh
make watcher_deploy
```

### To Uninstall OLM deployed watcher-operator

**Undeploy watcher service

```sh
make watcher_deploy_cleanup
```

**Uninstall watcher-operator

```sh
make watcher_cleanup
```

## Project Distribution

Following are the steps to build the installer and distribute this project to users.
Expand Down
36 changes: 36 additions & 0 deletions ci/olm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cat > ci/olm.yaml <<EOF_CAT
---
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_CAT

0 comments on commit 95db9af

Please sign in to comment.