Skip to content

Commit 34a9f04

Browse files
Merge pull request #748 from karelyatin/custom_webhook_port
Make local webhook port configurable
2 parents 756d992 + c4a0a15 commit 34a9f04

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ SKIP_CERT ?=false
353353
run-with-webhook: export METRICS_PORT?=8080
354354
run-with-webhook: export HEALTH_PORT?=8081
355355
run-with-webhook: export PPROF_PORT?=8082
356+
run-with-webhook: export WEBHOOK_PORT?=9443
356357
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
357358
/bin/bash hack/run_with_local_webhook.sh
358359

hack/run_with_local_webhook.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ 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+
#Open ${WEBHOOK_PORT}
2021
if systemctl is-enabled firewalld; then
21-
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=9443/tcp
22+
sudo firewall-cmd --zone=${FIREWALL_ZONE} --add-port=${WEBHOOK_PORT}/tcp
2223
sudo firewall-cmd --runtime-to-permanent
2324
fi
2425

@@ -50,7 +51,7 @@ webhooks:
5051
- v1
5152
clientConfig:
5253
caBundle: ${CA_BUNDLE}
53-
url: https://${CRC_IP}:9443/validate-telemetry-openstack-org-v1beta1-autoscaling
54+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-telemetry-openstack-org-v1beta1-autoscaling
5455
failurePolicy: Fail
5556
matchPolicy: Equivalent
5657
name: vautoscaling.kb.io
@@ -78,7 +79,7 @@ webhooks:
7879
- v1
7980
clientConfig:
8081
caBundle: ${CA_BUNDLE}
81-
url: https://${CRC_IP}:9443/mutate-telemetry-openstack-org-v1beta1-autoscaling
82+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-telemetry-openstack-org-v1beta1-autoscaling
8283
failurePolicy: Fail
8384
matchPolicy: Equivalent
8485
name: mautoscaling.kb.io
@@ -106,7 +107,7 @@ webhooks:
106107
- v1
107108
clientConfig:
108109
caBundle: ${CA_BUNDLE}
109-
url: https://${CRC_IP}:9443/validate-telemetry-openstack-org-v1beta1-ceilometer
110+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-telemetry-openstack-org-v1beta1-ceilometer
110111
failurePolicy: Fail
111112
matchPolicy: Equivalent
112113
name: vtelemetry.kb.io
@@ -134,7 +135,7 @@ webhooks:
134135
- v1
135136
clientConfig:
136137
caBundle: ${CA_BUNDLE}
137-
url: https://${CRC_IP}:9443/mutate-telemetry-openstack-org-v1beta1-ceilometer
138+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-telemetry-openstack-org-v1beta1-ceilometer
138139
failurePolicy: Fail
139140
matchPolicy: Equivalent
140141
name: mtelemetry.kb.io
@@ -162,7 +163,7 @@ webhooks:
162163
- v1
163164
clientConfig:
164165
caBundle: ${CA_BUNDLE}
165-
url: https://${CRC_IP}:9443/validate-telemetry-openstack-org-v1beta1-telemetry
166+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-telemetry-openstack-org-v1beta1-telemetry
166167
failurePolicy: Fail
167168
matchPolicy: Equivalent
168169
name: vtelemetry.kb.io
@@ -190,7 +191,7 @@ webhooks:
190191
- v1
191192
clientConfig:
192193
caBundle: ${CA_BUNDLE}
193-
url: https://${CRC_IP}:9443/mutate-telemetry-openstack-org-v1beta1-telemetry
194+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-telemetry-openstack-org-v1beta1-telemetry
194195
failurePolicy: Fail
195196
matchPolicy: Equivalent
196197
name: mtelemetry.kb.io
@@ -218,7 +219,7 @@ webhooks:
218219
- v1
219220
clientConfig:
220221
caBundle: ${CA_BUNDLE}
221-
url: https://${CRC_IP}:9443/validate-telemetry-openstack-org-v1beta1-metricstorage
222+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-telemetry-openstack-org-v1beta1-metricstorage
222223
failurePolicy: Fail
223224
matchPolicy: Equivalent
224225
name: vmetricstorage.kb.io
@@ -246,7 +247,7 @@ webhooks:
246247
- v1
247248
clientConfig:
248249
caBundle: ${CA_BUNDLE}
249-
url: https://${CRC_IP}:9443/mutate-telemetry-openstack-org-v1beta1-metricstorage
250+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-telemetry-openstack-org-v1beta1-metricstorage
250251
failurePolicy: Fail
251252
matchPolicy: Equivalent
252253
name: mmetricstorage.kb.io
@@ -302,4 +303,4 @@ else
302303
oc scale --replicas=0 -n openstack-operators deploy/telemetry-operator-controller-manager
303304
fi
304305

305-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"
306+
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
@@ -91,11 +91,13 @@ func main() {
9191
var enableLeaderElection bool
9292
var probeAddr string
9393
var pprofBindAddress string
94+
var webhookPort int
9495
var enableHTTP2 bool
9596
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
9697
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8083", "The address the metric endpoint binds to.")
9798
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8084", "The address the probe endpoint binds to.")
9899
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
100+
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
99101
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
100102
"Enable leader election for controller manager. "+
101103
"Enabling this will ensure there is only one active controller manager.")
@@ -125,7 +127,7 @@ func main() {
125127
PprofBindAddress: pprofBindAddress,
126128
WebhookServer: webhook.NewServer(
127129
webhook.Options{
128-
Port: 9443,
130+
Port: webhookPort,
129131
TLSOpts: []func(config *tls.Config){disableHTTP2},
130132
}),
131133
}

0 commit comments

Comments
 (0)