Skip to content

Commit 9a4d22a

Browse files
Add manager flag to configure the maximum concurrent reconciles
This option defaults to 1. Which is also the default used by controller-runtime, see https://github.com/kubernetes-sigs/controller-runtime/blob/0c3a9102bc0af27b969b17191e68e6f28ff12c23/pkg/controller/controller.go#L49
1 parent 8b2800a commit 9a4d22a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func main() {
7676
var watchFilterValue string
7777
var providerName string
7878
var requeueInterval time.Duration
79+
var maxConcurrentReconciles int
7980
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
8081
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
8182
flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
@@ -90,6 +91,7 @@ func main() {
9091
flag.StringVar(&watchFilterValue, "watch-filter", "", fmt.Sprintf("Label value that the controller watches to reconcile api objects. Label key is always %q. If unspecified, the controller watches for all api objects.", v1alpha1.WatchLabel))
9192
flag.StringVar(&providerName, "provider", "openconfig", "The provider to use for the controller. If not specified, the default provider is used. Available providers: "+strings.Join(provider.Providers(), ", "))
9293
flag.DurationVar(&requeueInterval, "requeue-interval", 30*time.Second, "The interval after which Kubernetes resources should be reconciled again regardless of whether they have changed.")
94+
flag.IntVar(&maxConcurrentReconciles, "max-concurrent-reconciles", 1, "The maximum number of concurrent reconciles per controller. Defaults to 1.")
9395
opts := zap.Options{
9496
Development: true,
9597
TimeEncoder: zapcore.ISO8601TimeEncoder,
@@ -188,7 +190,7 @@ func main() {
188190

189191
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
190192
Cache: cache.Options{ReaderFailOnMissingInformer: true},
191-
Controller: config.Controller{UsePriorityQueue: ptr.To(true)},
193+
Controller: config.Controller{UsePriorityQueue: ptr.To(true), MaxConcurrentReconciles: maxConcurrentReconciles},
192194
Scheme: scheme,
193195
Metrics: metricsServerOptions,
194196
WebhookServer: webhookServer,

0 commit comments

Comments
 (0)