From a850279cbbf903c15c5c29ed307b5e21fc9609b9 Mon Sep 17 00:00:00 2001 From: Amine Date: Mon, 19 Jan 2026 21:49:00 -0800 Subject: [PATCH] feat: add enable-controller-warmup flag Wire EnableWarmup controller-runtime config to CLI flag and helm values. --- templates/cmd/controller/main.go.tpl | 6 ++++++ templates/helm/templates/deployment.yaml.tpl | 3 +++ templates/helm/values.yaml.tpl | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/templates/cmd/controller/main.go.tpl b/templates/cmd/controller/main.go.tpl index 74f65b15..3a1f820a 100644 --- a/templates/cmd/controller/main.go.tpl +++ b/templates/cmd/controller/main.go.tpl @@ -18,6 +18,7 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrlrt "sigs.k8s.io/controller-runtime" ctrlrtcache "sigs.k8s.io/controller-runtime/pkg/cache" + ctrlrtconfig "sigs.k8s.io/controller-runtime/pkg/config" ctrlrthealthz "sigs.k8s.io/controller-runtime/pkg/healthz" ctrlrtmetrics "sigs.k8s.io/controller-runtime/pkg/metrics" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" @@ -128,6 +129,11 @@ func main() { Host: host, }, }, + Controller: ctrlrtconfig.Controller{ + // EnableWarmup allows controllers to start their sources (watches/informers) before + // leader election is won. This pre-populates caches and improves leader failover time. + EnableWarmup: &ackCfg.EnableControllerWarmup, + }, Metrics: metricsserver.Options{BindAddress: ackCfg.MetricsAddr}, LeaderElection: ackCfg.EnableLeaderElection, LeaderElectionID: "ack-" + awsServiceAPIGroup, diff --git a/templates/helm/templates/deployment.yaml.tpl b/templates/helm/templates/deployment.yaml.tpl index 3c039908..0309eff0 100644 --- a/templates/helm/templates/deployment.yaml.tpl +++ b/templates/helm/templates/deployment.yaml.tpl @@ -77,6 +77,9 @@ spec: - --enable-leader-election - --leader-election-namespace - "$(LEADER_ELECTION_NAMESPACE)" +{{ "{{- if .Values.leaderElection.enableControllerWarmup }}" }} + - --enable-controller-warmup +{{ "{{- end }}" }} {{ "{{- end }}" }} {{ "{{- if gt (int .Values.reconcile.defaultResyncPeriod) 0 }}" }} - --reconcile-default-resync-seconds diff --git a/templates/helm/values.yaml.tpl b/templates/helm/values.yaml.tpl index d337ce6a..15617b62 100644 --- a/templates/helm/values.yaml.tpl +++ b/templates/helm/values.yaml.tpl @@ -173,6 +173,10 @@ leaderElection: # will attempt to use the namespace of the service account mounted to the Controller # pod. namespace: "" + # Enable controller warmup to start controller sources (watches/informers) before + # leader election is won. This pre-populates caches and improves leader failover time. + # Requires leader election to be enabled. + enableControllerWarmup: false # Enable Cross Account Resource Management (default = true). Set this to false to disable cross account resource management. enableCARM: true