Skip to content

Commit 4fa28a6

Browse files
Merge pull request #361 from karelyatin/custom_webhook_port
Make local webhook port configurable
2 parents e98cf89 + 04ff24a commit 4fa28a6

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
@@ -378,6 +378,7 @@ SKIP_CERT ?=false
378378
run-with-webhook: export METRICS_PORT?=8080
379379
run-with-webhook: export HEALTH_PORT?=8081
380380
run-with-webhook: export PPROF_PORT?=8082
381+
run-with-webhook: export WEBHOOK_PORT?=9443
381382
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
382383
/bin/bash hack/run_with_local_webhook.sh
383384

hack/run_with_local_webhook.sh

Lines changed: 8 additions & 7 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-mariadb-openstack-org-v1beta1-mariadb
52+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-mariadb-openstack-org-v1beta1-mariadb
5253
failurePolicy: Fail
5354
matchPolicy: Equivalent
5455
name: vmariadb.kb.io
@@ -70,7 +71,7 @@ webhooks:
7071
- v1
7172
clientConfig:
7273
caBundle: ${CA_BUNDLE}
73-
url: https://${CRC_IP}:9443/validate-mariadb-openstack-org-v1beta1-galera
74+
url: https://${CRC_IP}:${WEBHOOK_PORT}/validate-mariadb-openstack-org-v1beta1-galera
7475
failurePolicy: Fail
7576
matchPolicy: Equivalent
7677
name: vgalera.kb.io
@@ -98,7 +99,7 @@ webhooks:
9899
- v1
99100
clientConfig:
100101
caBundle: ${CA_BUNDLE}
101-
url: https://${CRC_IP}:9443/mutate-mariadb-openstack-org-v1beta1-mariadb
102+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-mariadb-openstack-org-v1beta1-mariadb
102103
failurePolicy: Fail
103104
matchPolicy: Equivalent
104105
name: mmariadb.kb.io
@@ -120,7 +121,7 @@ webhooks:
120121
- v1
121122
clientConfig:
122123
caBundle: ${CA_BUNDLE}
123-
url: https://${CRC_IP}:9443/mutate-mariadb-openstack-org-v1beta1-galera
124+
url: https://${CRC_IP}:${WEBHOOK_PORT}/mutate-mariadb-openstack-org-v1beta1-galera
124125
failurePolicy: Fail
125126
matchPolicy: Equivalent
126127
name: mgalera.kb.io
@@ -176,4 +177,4 @@ else
176177
oc scale --replicas=0 -n openstack-operators deploy/mariadb-operator-controller-manager
177178
fi
178179

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

0 commit comments

Comments
 (0)