Skip to content

Commit d70ef34

Browse files
Merge pull request #321 from karelyatin/custom_webhook_port
Make local webhook port configurable
2 parents 163d345 + 37f4c55 commit d70ef34

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ SKIP_CERT ?=false
390390
run-with-webhook: export METRICS_PORT?=8080
391391
run-with-webhook: export HEALTH_PORT?=8081
392392
run-with-webhook: export PPROF_PORT?=8082
393+
run-with-webhook: export WEBHOOK_PORT?=9443
393394
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
394395
/bin/bash hack/run_with_local_webhook.sh
395396

hack/run_with_local_webhook.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ TMPDIR=${TMPDIR:-"/tmp/k8s-webhook-server/serving-certs"}
1515
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"}
18+
WEBHOOK_PORT=${WEBHOOK_PORT:-${WEBHOOK_PORT}}
1819

19-
#Open 9443
20-
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=9443/tcp
20+
#Open ${WEBHOOK_PORT}
21+
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=${WEBHOOK_PORT}/tcp
2122
sudo firewall-cmd --runtime-to-permanent
2223

2324
# Generate the certs and the ca bundle
@@ -48,7 +49,7 @@ webhooks:
4849
- v1
4950
clientConfig:
5051
caBundle: ${CA_BUNDLE}
51-
url: https://${CRC_IP}:9443/validate-baremetal-openstack-org-v1beta1-openstackprovisionserver
52+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-baremetal-openstack-org-v1beta1-openstackprovisionserver
5253
failurePolicy: Fail
5354
matchPolicy: Equivalent
5455
name: vopenstackprovisionserver.kb.io
@@ -76,7 +77,7 @@ webhooks:
7677
- v1
7778
clientConfig:
7879
caBundle: ${CA_BUNDLE}
79-
url: https://${CRC_IP}:9443/mutate-baremetal-openstack-org-v1beta1-openstackprovisionserver
80+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-baremetal-openstack-org-v1beta1-openstackprovisionserver
8081
failurePolicy: Fail
8182
matchPolicy: Equivalent
8283
name: mopenstackprovisionserver.kb.io
@@ -104,7 +105,7 @@ webhooks:
104105
- v1
105106
clientConfig:
106107
caBundle: ${CA_BUNDLE}
107-
url: https://${CRC_IP}:9443/validate-baremetal-openstack-org-v1beta1-openstackbaremetalset
108+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-baremetal-openstack-org-v1beta1-openstackbaremetalset
108109
failurePolicy: Fail
109110
matchPolicy: Equivalent
110111
name: vopenstackbaremetalset.kb.io
@@ -161,4 +162,4 @@ else
161162
oc scale --replicas=0 -n openstack-operators deploy/openstack-baremetal-operator-controller-manager
162163
fi
163164

164-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
165+
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
@@ -63,11 +63,13 @@ func main() {
6363
var enableLeaderElection bool
6464
var probeAddr string
6565
var pprofBindAddress string
66+
var webhookPort int
6667
var enableHTTP2 bool
6768
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
6869
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8083", "The address the metric endpoint binds to.")
6970
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
7071
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
72+
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
7173
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
7274
"Enable leader election for controller manager. "+
7375
"Enabling this will ensure there is only one active controller manager.")
@@ -97,7 +99,7 @@ func main() {
9799
PprofBindAddress: pprofBindAddress,
98100
WebhookServer: webhook.NewServer(
99101
webhook.Options{
100-
Port: 9443,
102+
Port: webhookPort,
101103
TLSOpts: []func(config *tls.Config){disableHTTP2},
102104
}),
103105
}

0 commit comments

Comments
 (0)