Skip to content

Commit 40d18a7

Browse files
Merge pull request #623 from karelyatin/custom_webhook_port
Make local webhook port configurable
2 parents 5ac38a6 + 5872e52 commit 40d18a7

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ SKIP_CERT ?=false
370370
run-with-webhook: export METRICS_PORT?=8080
371371
run-with-webhook: export HEALTH_PORT?=8081
372372
run-with-webhook: export PPROF_PORT?=8082
373+
run-with-webhook: export WEBHOOK_PORT?=9443
373374
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
374375
/bin/bash hack/run_with_local_webhook.sh
375376

hack/run_with_local_webhook.sh

Lines changed: 6 additions & 5 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-keystone-openstack-org-v1beta1-keystoneapi
52+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-keystone-openstack-org-v1beta1-keystoneapi
5253
failurePolicy: Fail
5354
matchPolicy: Equivalent
5455
name: vkeystoneapi.kb.io
@@ -76,7 +77,7 @@ webhooks:
7677
- v1
7778
clientConfig:
7879
caBundle: ${CA_BUNDLE}
79-
url: https://${CRC_IP}:9443/mutate-keystone-openstack-org-v1beta1-keystoneapi
80+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-keystone-openstack-org-v1beta1-keystoneapi
8081
failurePolicy: Fail
8182
matchPolicy: Equivalent
8283
name: mkeystoneapi.kb.io
@@ -132,4 +133,4 @@ else
132133
oc scale --replicas=0 -n openstack-operators deploy/keystone-operator-controller-manager
133134
fi
134135

135-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
136+
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
@@ -72,11 +72,13 @@ func main() {
7272
var enableLeaderElection bool
7373
var probeAddr string
7474
var pprofBindAddress string
75+
var webhookPort int
7576
var enableHTTP2 bool
7677
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
7778
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
7879
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
7980
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
81+
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
8082
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8183
"Enable leader election for controller manager. "+
8284
"Enabling this will ensure there is only one active controller manager.")
@@ -106,7 +108,7 @@ func main() {
106108
PprofBindAddress: pprofBindAddress,
107109
WebhookServer: webhook.NewServer(
108110
webhook.Options{
109-
Port: 9443,
111+
Port: webhookPort,
110112
TLSOpts: []func(config *tls.Config){disableHTTP2},
111113
}),
112114
}

0 commit comments

Comments
 (0)