Skip to content

Commit f477e28

Browse files
committed
Let disable webhooks
[This change](https://github.com/kubernetes-sigs/cluster-api/commit/280db9a796d5e1c2b3b75aa3036fcfe44f669909#diff-a46ea7e53a9e71ee7642[…]57385a613ca5d51cL170-L173) made webhooks to always run as part of the manager. I'd like to keep the ability to disable running webhooks. Motivation is as adopting and building atop CAPI I’d like to do so gradually, going all in once with webhooks increase complexisty and resistance. Also this is necessary to support other type than single controller deployments and should be part of this contract https://master.cluster-api.sigs.k8s.io/developer/architecture/controllers/support-multiple-instances.html#contract
1 parent df2ab2f commit f477e28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func InitFlags(fs *pflag.FlagSet) {
143143
"The minimum interval at which watched resources are reconciled (e.g. 15m)")
144144

145145
fs.IntVar(&webhookPort, "webhook-port", 9443,
146-
"Webhook Server port")
146+
"Webhook Server port. Set 0 to disable it.")
147147

148148
fs.StringVar(&webhookCertDir, "webhook-cert-dir", "/tmp/k8s-webhook-server/serving-certs/",
149149
"Webhook cert dir, only used when webhook-port is specified.")
@@ -311,6 +311,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
311311
}
312312

313313
func setupWebhooks(mgr ctrl.Manager) {
314+
if webhookPort == 0 {
315+
return
316+
}
317+
314318
if err := (&clusterv1.Cluster{}).SetupWebhookWithManager(mgr); err != nil {
315319
setupLog.Error(err, "unable to create webhook", "webhook", "Cluster")
316320
os.Exit(1)

0 commit comments

Comments
 (0)