Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var (
webhookCertDir string
healthAddr string
watchConfigSecretChanges bool
watchConfigMapChanges bool
managerOptions = flags.ManagerOptions{}
)

Expand Down Expand Up @@ -103,6 +104,9 @@ func InitFlags(fs *pflag.FlagSet) {
fs.BoolVar(&watchConfigSecretChanges, "watch-configsecret", false,
"Watch for changes to the ConfigSecret resource and reconcile all providers using it.")

fs.BoolVar(&watchConfigMapChanges, "watch-configmap", false,
"Watch for changes to ConfigMaps used by providers with fetchConfig.selector and reconcile all providers using them.")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

Expand Down Expand Up @@ -201,7 +205,7 @@ func main() {
ctx := ctrl.SetupSignalHandler()

setupChecks(mgr)
setupReconcilers(ctx, mgr, watchConfigSecretChanges)
setupReconcilers(ctx, mgr, watchConfigSecretChanges, watchConfigMapChanges)
setupWebhooks(mgr)

// +kubebuilder:scaffold:builder
Expand All @@ -225,13 +229,14 @@ func setupChecks(mgr ctrl.Manager) {
}
}

func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretChanges bool) {
func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretChanges, watchConfigMapChanges bool) {
if err := (&providercontroller.GenericProviderReconciler{
Provider: &operatorv1.CoreProvider{},
ProviderList: &operatorv1.CoreProviderList{},
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CoreProvider")
os.Exit(1)
Expand All @@ -243,6 +248,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretCh
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
WatchCoreProviderChanges: true,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "InfrastructureProvider")
Expand All @@ -255,6 +261,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretCh
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
WatchCoreProviderChanges: true,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "BootstrapProvider")
Expand All @@ -267,6 +274,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretCh
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
WatchCoreProviderChanges: true,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ControlPlaneProvider")
Expand All @@ -279,6 +287,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretCh
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
WatchCoreProviderChanges: true,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AddonProvider")
Expand All @@ -291,6 +300,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretCh
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
WatchCoreProviderChanges: true,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "IPAMProvider")
Expand All @@ -303,6 +313,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchConfigSecretCh
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
WatchConfigSecretChanges: watchConfigSecretChanges,
WatchConfigMapChanges: watchConfigMapChanges,
WatchCoreProviderChanges: true,
}).SetupWithManager(ctx, mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "RuntimeExtensionProvider")
Expand Down
3 changes: 3 additions & 0 deletions hack/charts/cluster-api-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ spec:
{{- if .Values.watchConfigSecret }}
- --watch-configsecret
{{- end }}
{{- if .Values.watchConfigMap }}
- --watch-configmap
{{- end }}
{{- with .Values.leaderElection }}
- --leader-elect={{ .enabled }}
{{- if .leaseDuration }}
Expand Down
1 change: 1 addition & 0 deletions hack/charts/cluster-api-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ profilerAddress: ":6060"
contentionProfiling: false
insecureDiagnostics: false
watchConfigSecret: false
watchConfigMap: false
imagePullSecrets: {}
resources:
manager:
Expand Down
Loading
Loading