Skip to content
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ SKIP_CERT ?=false
run-with-webhook: export METRICS_PORT?=8080
run-with-webhook: export HEALTH_PORT?=8081
run-with-webhook: export PPROF_PORT?=8082
run-with-webhook: export WEBHOOK_PORT?=9443
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
/bin/bash hack/run_with_local_webhook.sh

Expand Down
31 changes: 16 additions & 15 deletions hack/run_with_local_webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ trap cleanup SIGINT SIGTERM
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)}
WEBHOOK_PORT=${WEBHOOK_PORT:-${WEBHOOK_PORT}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually i changed it all the repos by keeping the port define only at one place in Makefile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we don't expect anyone to use this script directly outside of calling it from the Makefile target (which sets the default), so this seems fine.


#Open 9443
sudo firewall-cmd --zone=libvirt --add-port=9443/tcp || :
#Open ${WEBHOOK_PORT}
sudo firewall-cmd --zone=libvirt --add-port=${WEBHOOK_PORT}/tcp || :
sudo firewall-cmd --runtime-to-permanent || :

# Generate the certs and the ca bundle
Expand Down Expand Up @@ -48,7 +49,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/validate-core-openstack-org-v1beta1-openstackcontrolplane
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-core-openstack-org-v1beta1-openstackcontrolplane
failurePolicy: Fail
matchPolicy: Equivalent
name: vopenstackcontrolplane.kb.io
Expand Down Expand Up @@ -76,7 +77,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/validate-client-openstack-org-v1beta1-openstackclient
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-client-openstack-org-v1beta1-openstackclient
failurePolicy: Fail
matchPolicy: Equivalent
name: vopenstackclient.kb.io
Expand Down Expand Up @@ -104,7 +105,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/validate-core-openstack-org-v1beta1-openstackversion
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-core-openstack-org-v1beta1-openstackversion
failurePolicy: Fail
matchPolicy: Equivalent
name: vopenstackversion.kb.io
Expand Down Expand Up @@ -132,7 +133,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/mutate-core-openstack-org-v1beta1-openstackcontrolplane
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-core-openstack-org-v1beta1-openstackcontrolplane
failurePolicy: Fail
matchPolicy: Equivalent
name: mopenstackcontrolplane.kb.io
Expand Down Expand Up @@ -160,7 +161,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/mutate-client-openstack-org-v1beta1-openstackclient
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-client-openstack-org-v1beta1-openstackclient
failurePolicy: Fail
matchPolicy: Equivalent
name: mopenstackclient.kb.io
Expand Down Expand Up @@ -188,7 +189,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/mutate-core-openstack-org-v1beta1-openstackversion
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-core-openstack-org-v1beta1-openstackversion
failurePolicy: Fail
matchPolicy: Equivalent
name: mopenstackversion.kb.io
Expand Down Expand Up @@ -216,7 +217,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/validate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
failurePolicy: Fail
matchPolicy: Equivalent
name: vopenstackdataplanenodeset.kb.io
Expand Down Expand Up @@ -244,7 +245,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/mutate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
failurePolicy: Fail
matchPolicy: Equivalent
name: mopenstackdataplanenodeset.kb.io
Expand Down Expand Up @@ -272,7 +273,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/validate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
failurePolicy: Fail
matchPolicy: Equivalent
name: vopenstackdataplanedeployment.kb.io
Expand Down Expand Up @@ -300,7 +301,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/mutate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
failurePolicy: Fail
matchPolicy: Equivalent
name: mopenstackdataplanedeployment.kb.io
Expand Down Expand Up @@ -328,7 +329,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/validate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
failurePolicy: Fail
matchPolicy: Equivalent
name: vopenstackdataplaneservice.kb.io
Expand Down Expand Up @@ -356,7 +357,7 @@ webhooks:
- v1
clientConfig:
caBundle: ${CA_BUNDLE}
url: https://${CRC_IP}:9443/mutate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
failurePolicy: Fail
matchPolicy: Equivalent
name: mopenstackdataplaneservice.kb.io
Expand Down Expand Up @@ -402,4 +403,4 @@ if [ -n "${CSV_NAME}" ]; then
fi

source hack/export_related_images.sh && \
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}" -webhook-bind-address "${WEBHOOK_PORT}"
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ func main() {
var enableLeaderElection bool
var probeAddr string
var pprofAddr string
var webhookPort int
var enableHTTP2 bool
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.StringVar(&pprofAddr, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof")
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand Down Expand Up @@ -184,7 +186,7 @@ func main() {
LeaderElectionID: "40ba705e.openstack.org",
WebhookServer: webhook.NewServer(
webhook.Options{
Port: 9443,
Port: webhookPort,
TLSOpts: []func(config *tls.Config){disableHTTP2},
}),
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
Expand Down