Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve make run-with-webhook #115

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,27 @@ operator-lint: gowork ## Runs operator-lint
GOBIN=$(LOCALBIN) go install github.com/gibizer/[email protected]
go vet -vettool=$(LOCALBIN)/operator-lint ./... ./api/...

# Used for webhook testing
# Please ensure the placement-controller-manager deployment and
# webhook definitions are removed from the csv before running
# this. Also, cleanup the webhook configuration for local testing
# before deplying with olm again.
# $oc delete -n openstack validatingwebhookconfiguration/vplacementapi.kb.io
# $oc delete -n openstack mutatingwebhookconfiguration/mplacementapi.kb.io
SKIP_CERT ?=false
.PHONY: run-with-webhook
run-with-webhook: export METRICS_PORT?=8080
run-with-webhook: export HEALTH_PORT?=8081
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
run-with-webhook: manifests generate fmt vet scale-down-placement-controller-csv ## Run a controller from your host.
/bin/bash hack/clean_local_webhook.sh
/bin/bash hack/configure_local_webhook.sh
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"

.PHONY: tidy
tidy: ## Run go mod tidy on every mod file in the repo
go mod tidy
cd ./api && go mod tidy

OPERATOR_NAMESPACE ?= openstack-operators

scale-down-placement-controller-csv:
@echo "Scaling placement-controller-manager to 0 in CSV"
oc patch csv -n $(OPERATOR_NAMESPACE) placement-operator.v0.0.1 --type json -p='[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/replicas", "value": 0}]'
@echo "Removing olm installed webhooks from CSV"
$(eval has_webhooks=$(shell oc get -o json csv placement-operator.v0.0.1 | jq ".spec.webhookdefinitions"))
if [ "$(has_webhooks)" != "null" ]; then \
oc patch csv -n $(OPERATOR_NAMESPACE) placement-operator.v0.0.1 --type json -p='[{"op": "remove", "path": "/spec/webhookdefinitions"}]'; \
fi
9 changes: 6 additions & 3 deletions hack/configure_local_webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ TMPDIR=${TMPDIR:-"/tmp/k8s-webhook-server/serving-certs"}
SKIP_CERT=${SKIP_CERT:-false}
CRC_IP=${CRC_IP:-$(/sbin/ip -o -4 addr list crc | awk '{print $4}' | cut -d/ -f1)}
FIREWALL_ZONE=${FIREWALL_ZONE:-"libvirt"}
SKIP_FIREWALL=${SKIP_FIREWALL:-false}

#Open 9443
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=9443/tcp
sudo firewall-cmd --runtime-to-permanent
if [ "$SKIP_FIREWALL" = false ] ; then
#Open 9443
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=9443/tcp
sudo firewall-cmd --runtime-to-permanent
fi

# Generate the certs and the ca bundle
if [ "$SKIP_CERT" = false ] ; then
Expand Down