Skip to content

Commit c3dd6bb

Browse files
committed
Make local webhook port configurable
Will be helpful when running multiple operators locally
1 parent 6d1b903 commit c3dd6bb

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ SKIP_CERT ?=false
509509
run-with-webhook: export METRICS_PORT?=8080
510510
run-with-webhook: export HEALTH_PORT?=8081
511511
run-with-webhook: export PPROF_PORT?=8082
512+
run-with-webhook: export WEBHOOK_PORT?=9443
512513
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
513514
/bin/bash hack/run_with_local_webhook.sh
514515

hack/run_with_local_webhook.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ 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

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

2222
# Generate the certs and the ca bundle
@@ -48,7 +48,7 @@ webhooks:
4848
- v1
4949
clientConfig:
5050
caBundle: ${CA_BUNDLE}
51-
url: https://${CRC_IP}:9443/validate-core-openstack-org-v1beta1-openstackcontrolplane
51+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-core-openstack-org-v1beta1-openstackcontrolplane
5252
failurePolicy: Fail
5353
matchPolicy: Equivalent
5454
name: vopenstackcontrolplane.kb.io
@@ -76,7 +76,7 @@ webhooks:
7676
- v1
7777
clientConfig:
7878
caBundle: ${CA_BUNDLE}
79-
url: https://${CRC_IP}:9443/validate-client-openstack-org-v1beta1-openstackclient
79+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-client-openstack-org-v1beta1-openstackclient
8080
failurePolicy: Fail
8181
matchPolicy: Equivalent
8282
name: vopenstackclient.kb.io
@@ -104,7 +104,7 @@ webhooks:
104104
- v1
105105
clientConfig:
106106
caBundle: ${CA_BUNDLE}
107-
url: https://${CRC_IP}:9443/validate-core-openstack-org-v1beta1-openstackversion
107+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-core-openstack-org-v1beta1-openstackversion
108108
failurePolicy: Fail
109109
matchPolicy: Equivalent
110110
name: vopenstackversion.kb.io
@@ -132,7 +132,7 @@ webhooks:
132132
- v1
133133
clientConfig:
134134
caBundle: ${CA_BUNDLE}
135-
url: https://${CRC_IP}:9443/mutate-core-openstack-org-v1beta1-openstackcontrolplane
135+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-core-openstack-org-v1beta1-openstackcontrolplane
136136
failurePolicy: Fail
137137
matchPolicy: Equivalent
138138
name: mopenstackcontrolplane.kb.io
@@ -160,7 +160,7 @@ webhooks:
160160
- v1
161161
clientConfig:
162162
caBundle: ${CA_BUNDLE}
163-
url: https://${CRC_IP}:9443/mutate-client-openstack-org-v1beta1-openstackclient
163+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-client-openstack-org-v1beta1-openstackclient
164164
failurePolicy: Fail
165165
matchPolicy: Equivalent
166166
name: mopenstackclient.kb.io
@@ -188,7 +188,7 @@ webhooks:
188188
- v1
189189
clientConfig:
190190
caBundle: ${CA_BUNDLE}
191-
url: https://${CRC_IP}:9443/mutate-core-openstack-org-v1beta1-openstackversion
191+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-core-openstack-org-v1beta1-openstackversion
192192
failurePolicy: Fail
193193
matchPolicy: Equivalent
194194
name: mopenstackversion.kb.io
@@ -216,7 +216,7 @@ webhooks:
216216
- v1
217217
clientConfig:
218218
caBundle: ${CA_BUNDLE}
219-
url: https://${CRC_IP}:9443/validate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
219+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
220220
failurePolicy: Fail
221221
matchPolicy: Equivalent
222222
name: vopenstackdataplanenodeset.kb.io
@@ -244,7 +244,7 @@ webhooks:
244244
- v1
245245
clientConfig:
246246
caBundle: ${CA_BUNDLE}
247-
url: https://${CRC_IP}:9443/mutate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
247+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-dataplane-openstack-org-v1beta1-openstackdataplanenodeset
248248
failurePolicy: Fail
249249
matchPolicy: Equivalent
250250
name: mopenstackdataplanenodeset.kb.io
@@ -272,7 +272,7 @@ webhooks:
272272
- v1
273273
clientConfig:
274274
caBundle: ${CA_BUNDLE}
275-
url: https://${CRC_IP}:9443/validate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
275+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
276276
failurePolicy: Fail
277277
matchPolicy: Equivalent
278278
name: vopenstackdataplanedeployment.kb.io
@@ -300,7 +300,7 @@ webhooks:
300300
- v1
301301
clientConfig:
302302
caBundle: ${CA_BUNDLE}
303-
url: https://${CRC_IP}:9443/mutate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
303+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-dataplane-openstack-org-v1beta1-openstackdataplanedeployment
304304
failurePolicy: Fail
305305
matchPolicy: Equivalent
306306
name: mopenstackdataplanedeployment.kb.io
@@ -328,7 +328,7 @@ webhooks:
328328
- v1
329329
clientConfig:
330330
caBundle: ${CA_BUNDLE}
331-
url: https://${CRC_IP}:9443/validate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
331+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
332332
failurePolicy: Fail
333333
matchPolicy: Equivalent
334334
name: vopenstackdataplaneservice.kb.io
@@ -356,7 +356,7 @@ webhooks:
356356
- v1
357357
clientConfig:
358358
caBundle: ${CA_BUNDLE}
359-
url: https://${CRC_IP}:9443/mutate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
359+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-dataplane-openstack-org-v1beta1-openstackdataplaneservice
360360
failurePolicy: Fail
361361
matchPolicy: Equivalent
362362
name: mopenstackdataplaneservice.kb.io
@@ -402,4 +402,4 @@ if [ -n "${CSV_NAME}" ]; then
402402
fi
403403

404404
source hack/export_related_images.sh && \
405-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
405+
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func main() {
150150
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
151151
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
152152
flag.StringVar(&pprofAddr, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof")
153+
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
153154
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
154155
"Enable leader election for controller manager. "+
155156
"Enabling this will ensure there is only one active controller manager.")
@@ -184,7 +185,7 @@ func main() {
184185
LeaderElectionID: "40ba705e.openstack.org",
185186
WebhookServer: webhook.NewServer(
186187
webhook.Options{
187-
Port: 9443,
188+
Port: webhookPort,
188189
TLSOpts: []func(config *tls.Config){disableHTTP2},
189190
}),
190191
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily

0 commit comments

Comments
 (0)