Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow configuring reconciliation concurrency #628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions charts/ingressmonitorcontroller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ spec:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --max-concurrent-reconciles={{ .Values.maxConcurrentReconciles }}
command:
- /manager
env:
Expand Down
3 changes: 3 additions & 0 deletions charts/ingressmonitorcontroller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespaceOverride: ""
# Leave empty for full access or specify a comma separated list of namespaces to watch
watchNamespaces: ""

# Number of concurrent reconciles
maxConcurrentReconciles: 1

# Name of secret containing
configSecretName: "imc-config"

Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
var maxConcurrentReconciles int
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.IntVar(&maxConcurrentReconciles, "max-concurrent-reconciles", 1,
"The maximum number of concurrent Reconciles which can be run.",
)
opts := zap.Options{
Development: false,
}
Expand Down Expand Up @@ -111,7 +115,7 @@ func main() {
Log: ctrl.Log.WithName("controllers").WithName("EndpointMonitor"),
Scheme: mgr.GetScheme(),
MonitorServices: monitors.SetupMonitorServicesForProviders(config.Providers),
}).SetupWithManager(mgr); err != nil {
}).SetupWithManager(mgr, maxConcurrentReconciles); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "EndpointMonitor")
os.Exit(1)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/controllers/endpointmonitor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

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

// SetupWithManager sets up the controller with the Manager.
func (r *EndpointMonitorReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *EndpointMonitorReconciler) SetupWithManager(mgr ctrl.Manager, maxConcurrentReconciles int) error {
return ctrl.NewControllerManagedBy(mgr).
WithOptions(controller.Options{
MaxConcurrentReconciles: maxConcurrentReconciles,
}).
For(&endpointmonitorv1alpha1.EndpointMonitor{}).
Complete(r)
}
Expand Down