Skip to content

Commit e874ba1

Browse files
Make local webhook port configurable
Will be helpful when running multiple operators locally
1 parent a68262c commit e874ba1

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ SKIP_CERT ?=false
389389
run-with-webhook: export METRICS_PORT?=24600
390390
run-with-webhook: export HEALTH_PORT?=24601
391391
run-with-webhook: export PPROF_PORT?=8082
392+
run-with-webhook: export WEBHOOK_PORT?=9444
392393
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
393394
/bin/bash hack/clean_local_webhook.sh
394395
/bin/bash hack/run_with_local_webhook.sh

hack/run_with_local_webhook.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SKIP_CERT=${SKIP_CERT:-false}
1616
CRC_IP=${CRC_IP:-$(/sbin/ip -o -4 addr list crc | awk '{print $4}' | cut -d/ -f1)}
1717
FIREWALL_ZONE=${FIREWALL_ZONE:-"libvirt"}
1818
SKIP_FIREWALL=${SKIP_FIREWALL:-false}
19-
WEBHOOK_PORT=9444
19+
WEBHOOK_PORT=${WEBHOOK_PORT:-${WEBHOOK_PORT}}
2020

2121
if [ "$SKIP_FIREWALL" = false ] ; then
2222
#Open ${WEBHOOK_PORT}
@@ -528,4 +528,4 @@ else
528528
oc scale --replicas=0 -n openstack-operators deploy/nova-operator-controller-manager
529529
fi
530530

531-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
531+
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}"

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ func main() {
8181
var enableLeaderElection bool
8282
var probeAddr string
8383
var pprofBindAddress string
84+
var webhookPort int
8485
var enableHTTP2 bool
8586
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
8687
flag.StringVar(&metricsAddr, "metrics-bind-address", ":24600", "The address the metric endpoint binds to.")
8788
flag.StringVar(&probeAddr, "health-probe-bind-address", ":24601", "The address the probe endpoint binds to.")
8889
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
90+
flag.IntVar(&webhookPort, "webhook-bind-address", 9444, "The port the webhook server binds to.")
8991
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
9092
"Enable leader election for controller manager. "+
9193
"Enabling this will ensure there is only one active controller manager.")
@@ -116,7 +118,7 @@ func main() {
116118
PprofBindAddress: pprofBindAddress,
117119
WebhookServer: webhook.NewServer(
118120
webhook.Options{
119-
Port: 9444,
121+
Port: webhookPort,
120122
TLSOpts: []func(config *tls.Config){disableHTTP2},
121123
}),
122124
}

0 commit comments

Comments
 (0)