Skip to content

Commit 7ec9dea

Browse files
Merge pull request #792 from karelyatin/custom_webhook_port
Make local webhook port configurable
2 parents 1ec8a96 + 95f5d60 commit 7ec9dea

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ SKIP_CERT ?=false
385385
run-with-webhook: export METRICS_PORT?=8080
386386
run-with-webhook: export HEALTH_PORT?=8081
387387
run-with-webhook: export PPROF_PORT?=8082
388+
run-with-webhook: export WEBHOOK_PORT?=9443
388389
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
389390
/bin/bash hack/run_with_local_webhook.sh
390391

hack/run_with_local_webhook.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ trap cleanup SIGINT SIGTERM
1414
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)}
17+
WEBHOOK_PORT=${WEBHOOK_PORT:-${WEBHOOK_PORT}}
1718

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

2223
# Generate the certs and the ca bundle
@@ -47,7 +48,7 @@ webhooks:
4748
- v1
4849
clientConfig:
4950
caBundle: ${CA_BUNDLE}
50-
url: https://${CRC_IP}:9443/validate-glance-openstack-org-v1beta1-glance
51+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-glance-openstack-org-v1beta1-glance
5152
failurePolicy: Fail
5253
matchPolicy: Equivalent
5354
name: vglance.kb.io
@@ -75,7 +76,7 @@ webhooks:
7576
- v1
7677
clientConfig:
7778
caBundle: ${CA_BUNDLE}
78-
url: https://${CRC_IP}:9443/mutate-glance-openstack-org-v1beta1-glance
79+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-glance-openstack-org-v1beta1-glance
7980
failurePolicy: Fail
8081
matchPolicy: Equivalent
8182
name: mglance.kb.io
@@ -103,7 +104,7 @@ webhooks:
103104
- v1
104105
clientConfig:
105106
caBundle: ${CA_BUNDLE}
106-
url: https://${CRC_IP}:9443/validate-glance-openstack-org-v1beta1-glanceapi
107+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-glance-openstack-org-v1beta1-glanceapi
107108
failurePolicy: Fail
108109
matchPolicy: Equivalent
109110
name: vglanceapi.kb.io
@@ -131,7 +132,7 @@ webhooks:
131132
- v1
132133
clientConfig:
133134
caBundle: ${CA_BUNDLE}
134-
url: https://${CRC_IP}:9443/mutate-glance-openstack-org-v1beta1-glanceapi
135+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-glance-openstack-org-v1beta1-glanceapi
135136
failurePolicy: Fail
136137
matchPolicy: Equivalent
137138
name: mglanceapi.kb.io
@@ -187,4 +188,4 @@ else
187188
oc scale --replicas=0 -n openstack-operators deploy/glance-operator-controller-manager
188189
fi
189190

190-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
191+
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
@@ -78,11 +78,13 @@ func main() {
7878
var enableLeaderElection bool
7979
var probeAddr string
8080
var pprofBindAddress string
81+
var webhookPort int
8182
var enableHTTP2 bool
8283
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
8384
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
8485
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
8586
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
87+
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
8688
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8789
"Enable leader election for controller manager. "+
8890
"Enabling this will ensure there is only one active controller manager.")
@@ -112,7 +114,7 @@ func main() {
112114
PprofBindAddress: pprofBindAddress,
113115
WebhookServer: webhook.NewServer(
114116
webhook.Options{
115-
Port: 9443,
117+
Port: webhookPort,
116118
TLSOpts: []func(config *tls.Config){disableHTTP2},
117119
}),
118120
}

0 commit comments

Comments
 (0)