Skip to content

Commit f0d78e6

Browse files
authored
feat: allow configuring reconciliation concurrency (#628)
* feat: allow configuring reconciliation concurrency * fix: add maxConcurrentReconciles option in chart
1 parent 07a1390 commit f0d78e6

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

charts/ingressmonitorcontroller/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ spec:
5252
- --health-probe-bind-address=:8081
5353
- --metrics-bind-address=127.0.0.1:8080
5454
- --leader-elect
55+
- --max-concurrent-reconciles={{ .Values.maxConcurrentReconciles }}
5556
command:
5657
- /manager
5758
env:

charts/ingressmonitorcontroller/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ namespaceOverride: ""
4141
# Leave empty for full access or specify a comma separated list of namespaces to watch
4242
watchNamespaces: ""
4343

44+
# Number of concurrent reconciles
45+
maxConcurrentReconciles: 1
46+
4447
# Name of secret containing
4548
configSecretName: "imc-config"
4649

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ func main() {
5959
var metricsAddr string
6060
var enableLeaderElection bool
6161
var probeAddr string
62+
var maxConcurrentReconciles int
6263
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
6364
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
6465
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
6566
"Enable leader election for controller manager. "+
6667
"Enabling this will ensure there is only one active controller manager.")
68+
flag.IntVar(&maxConcurrentReconciles, "max-concurrent-reconciles", 1,
69+
"The maximum number of concurrent Reconciles which can be run.",
70+
)
6771
opts := zap.Options{
6872
Development: false,
6973
}
@@ -111,7 +115,7 @@ func main() {
111115
Log: ctrl.Log.WithName("controllers").WithName("EndpointMonitor"),
112116
Scheme: mgr.GetScheme(),
113117
MonitorServices: monitors.SetupMonitorServicesForProviders(config.Providers),
114-
}).SetupWithManager(mgr); err != nil {
118+
}).SetupWithManager(mgr, maxConcurrentReconciles); err != nil {
115119
setupLog.Error(err, "unable to create controller", "controller", "EndpointMonitor")
116120
os.Exit(1)
117121
}

pkg/controllers/endpointmonitor_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/runtime"
3030
ctrl "sigs.k8s.io/controller-runtime"
3131
"sigs.k8s.io/controller-runtime/pkg/client"
32+
"sigs.k8s.io/controller-runtime/pkg/controller"
3233
logf "sigs.k8s.io/controller-runtime/pkg/log"
3334
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3435

@@ -105,8 +106,11 @@ func (r *EndpointMonitorReconciler) Reconcile(ctx context.Context, req ctrl.Requ
105106
}
106107

107108
// SetupWithManager sets up the controller with the Manager.
108-
func (r *EndpointMonitorReconciler) SetupWithManager(mgr ctrl.Manager) error {
109+
func (r *EndpointMonitorReconciler) SetupWithManager(mgr ctrl.Manager, maxConcurrentReconciles int) error {
109110
return ctrl.NewControllerManagedBy(mgr).
111+
WithOptions(controller.Options{
112+
MaxConcurrentReconciles: maxConcurrentReconciles,
113+
}).
110114
For(&endpointmonitorv1alpha1.EndpointMonitor{}).
111115
Complete(r)
112116
}

0 commit comments

Comments
 (0)