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