Skip to content

Commit a45a87e

Browse files
committed
Automate OLM cleanup for running local operator w/ webhooks
1 parent 7db9a74 commit a45a87e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,11 @@ operator-lint: gowork ## Runs operator-lint
341341
go vet -vettool=$(LOCALBIN)/operator-lint ./... ./api/...
342342

343343
# Used for webhook testing
344-
# Please ensure the octavia-controller-manager deployment and
345-
# webhook definitions are removed from the csv before running
346-
# this. Also, cleanup the webhook configuration for local testing
347-
# before deplying with olm again.
348-
# $oc delete -n openstack validatingwebhookconfiguration/voctavia.kb.io
349-
# $oc delete -n openstack mutatingwebhookconfiguration/moctavia.kb.io
344+
# The configure_local_webhooks.sh script below will remove any OLM webhooks
345+
# for the operator and also scale its deployment replicas down to 0 so that
346+
# the operator can run locally.
347+
# Make sure to cleanup the webhook configuration for local testing by running
348+
# ./hack/clean_local_webhook.sh before deplying with OLM again.
350349
SKIP_CERT ?=false
351350
.PHONY: run-with-webhook
352351
run-with-webhook: export METRICS_PORT?=8080

hack/configure_local_webhook.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,11 @@ webhooks:
8686
EOF_CAT
8787

8888
oc apply -n openstack -f ${TMPDIR}/patch_webhook_configurations.yaml
89+
90+
# Scale-down operator deployment replicas to zero and remove OLM webhooks
91+
CSV_NAME="$(oc get csv -n openstack-operators -l operators.coreos.com/octavia-operator.openstack-operators -o name)"
92+
93+
if [ -n "${CSV_NAME}" ]; then
94+
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/install/spec/deployments/0/spec/replicas', 'value': 0}]"
95+
oc patch "${CSV_NAME}" -n openstack-operators --type=json -p="[{'op': 'replace', 'path': '/spec/webhookdefinitions', 'value': []}]"
96+
fi

0 commit comments

Comments
 (0)