@@ -67,6 +67,7 @@ import (
67
67
"sigs.k8s.io/cluster-api-provider-azure/feature"
68
68
"sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing"
69
69
"sigs.k8s.io/cluster-api-provider-azure/pkg/ot"
70
+ "sigs.k8s.io/cluster-api-provider-azure/util/components"
70
71
"sigs.k8s.io/cluster-api-provider-azure/util/reconciler"
71
72
"sigs.k8s.io/cluster-api-provider-azure/version"
72
73
)
@@ -120,6 +121,7 @@ var (
120
121
managerOptions = flags.ManagerOptions {}
121
122
timeouts reconciler.Timeouts
122
123
enableTracing bool
124
+ disableControllersOrWebhooks []string
123
125
)
124
126
125
127
// InitFlags initializes all command-line flags.
@@ -266,6 +268,12 @@ func InitFlags(fs *pflag.FlagSet) {
266
268
"(Deprecated) Provide fully qualified GVK string to override default kubeadm config watch source, in the form of Kind.version.group (default: KubeadmConfig.v1beta1.bootstrap.cluster.x-k8s.io)" ,
267
269
)
268
270
271
+ fs .StringSliceVar (& disableControllersOrWebhooks ,
272
+ "disable-controllers-or-webhooks" ,
273
+ []string {},
274
+ "Comma-separated list of controllers or webhooks to disable. The list can contain the following values: DisableASOSecretController,DisableAzureJSONMachineController" ,
275
+ )
276
+
269
277
flags .AddManagerOptions (fs , & managerOptions )
270
278
271
279
feature .MutableGates .AddFlag (fs )
@@ -308,6 +316,16 @@ func main() {
308
316
}
309
317
}
310
318
319
+ // Validate valid disable components were passed in the flag
320
+ if len (disableControllersOrWebhooks ) > 0 {
321
+ for _ , component := range disableControllersOrWebhooks {
322
+ if ok := components .IsValidDisableComponent (component ); ! ok {
323
+ setupLog .Error (fmt .Errorf ("invalid disable-controllers-or-webhooks value %s" , component ), "Invalid argument" )
324
+ os .Exit (1 )
325
+ }
326
+ }
327
+ }
328
+
311
329
restConfig := ctrl .GetConfigOrDie ()
312
330
restConfig .UserAgent = "cluster-api-provider-azure-manager"
313
331
mgr , err := ctrl .NewManager (restConfig , ctrl.Options {
@@ -420,26 +438,30 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
420
438
os .Exit (1 )
421
439
}
422
440
423
- if err := (& controllers.AzureJSONMachineReconciler {
424
- Client : mgr .GetClient (),
425
- Recorder : mgr .GetEventRecorderFor ("azurejsonmachine-reconciler" ),
426
- Timeouts : timeouts ,
427
- WatchFilterValue : watchFilterValue ,
428
- CredentialCache : credCache ,
429
- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : azureMachineConcurrency , SkipNameValidation : ptr .To (true )}); err != nil {
430
- setupLog .Error (err , "unable to create controller" , "controller" , "AzureJSONMachine" )
431
- os .Exit (1 )
441
+ if ! components .IsComponentDisabled (disableControllersOrWebhooks , infrav1 .DisableAzureJSONMachineController ) {
442
+ if err := (& controllers.AzureJSONMachineReconciler {
443
+ Client : mgr .GetClient (),
444
+ Recorder : mgr .GetEventRecorderFor ("azurejsonmachine-reconciler" ),
445
+ Timeouts : timeouts ,
446
+ WatchFilterValue : watchFilterValue ,
447
+ CredentialCache : credCache ,
448
+ }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : azureMachineConcurrency , SkipNameValidation : ptr .To (true )}); err != nil {
449
+ setupLog .Error (err , "unable to create controller" , "controller" , "AzureJSONMachine" )
450
+ os .Exit (1 )
451
+ }
432
452
}
433
453
434
- if err := (& controllers.ASOSecretReconciler {
435
- Client : mgr .GetClient (),
436
- Recorder : mgr .GetEventRecorderFor ("asosecret-reconciler" ),
437
- Timeouts : timeouts ,
438
- WatchFilterValue : watchFilterValue ,
439
- CredentialCache : credCache ,
440
- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : azureClusterConcurrency }); err != nil {
441
- setupLog .Error (err , "unable to create controller" , "controller" , "ASOSecret" )
442
- os .Exit (1 )
454
+ if ! components .IsComponentDisabled (disableControllersOrWebhooks , infrav1 .DisableASOSecretController ) {
455
+ if err := (& controllers.ASOSecretReconciler {
456
+ Client : mgr .GetClient (),
457
+ Recorder : mgr .GetEventRecorderFor ("asosecret-reconciler" ),
458
+ Timeouts : timeouts ,
459
+ WatchFilterValue : watchFilterValue ,
460
+ CredentialCache : credCache ,
461
+ }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : azureClusterConcurrency }); err != nil {
462
+ setupLog .Error (err , "unable to create controller" , "controller" , "ASOSecret" )
463
+ os .Exit (1 )
464
+ }
443
465
}
444
466
445
467
// just use CAPI MachinePool feature flag rather than create a new one
0 commit comments