-
Notifications
You must be signed in to change notification settings - Fork 56
add options to tune concurrency, qps and burst #287
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,10 @@ func main() { | |
| var metricsCertDir string | ||
| var leaderElectionNamespace string | ||
| var enableNodeStateMetrics bool | ||
| var kubeAPIQPS float64 | ||
| var kubeAPIBurst int | ||
| var nodeConcurrentReconciles int | ||
| var ruleConcurrentReconciles int | ||
|
|
||
| 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.") | ||
|
|
@@ -84,6 +88,16 @@ func main() { | |
| flag.StringVar(&leaderElectionNamespace, "leader-election-namespace", "", "The namespace where the leader election resource will be created.") | ||
| flag.BoolVar(&enableNodeStateMetrics, "enable-node-state-metrics", false, | ||
| "Enable aggregate node state metrics on node updates)") | ||
| flag.Float64Var(&kubeAPIQPS, "kube-api-qps", 20, | ||
| "Maximum queries per second to the API server from this client. "+ | ||
| "Raise together with --kube-api-burst on large clusters.") | ||
| flag.IntVar(&kubeAPIBurst, "kube-api-burst", 30, | ||
| "Maximum burst for throttle between requests to the API server.") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this makes it simpler "maximum number of queries that should be allowed in one burst"
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any specific reason for keeping 20 and 30 or is it just to get started.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the current defaults set in controller runtime. I think we could adjust this after our experiments. Maybe I could add a comment to clarify these random numbers here
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, That would help, I looked at the default and saw its 5 and 10 https://github.com/kubernetes/client-go/blob/f16383b964b3519812bac4daf8f48fc5a529ae0f/rest/config.go#L118-L127, I am I looking at wrong place?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm.. I referred kcm default config here: https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager. looks like the controller-runtime had these hardcoded as defaults until recently: kubernetes-sigs/controller-runtime@ab40409
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the magic numbers, could we have them as constants? |
||
| flag.IntVar(&nodeConcurrentReconciles, "node-concurrent-reconciles", 1, | ||
| "Maximum number of Node objects reconciled concurrently. "+ | ||
| "Raise on large clusters to reduce readiness-taint latency during node join/condition updates.") | ||
| flag.IntVar(&ruleConcurrentReconciles, "rule-concurrent-reconciles", 1, | ||
| "Maximum number of NodeReadinessRule objects reconciled concurrently.") | ||
|
|
||
| opts := zap.Options{ | ||
| Development: true, | ||
|
|
@@ -107,7 +121,11 @@ func main() { | |
| }(), | ||
| } | ||
|
|
||
| mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ | ||
| restConfig := ctrl.GetConfigOrDie() | ||
| restConfig.QPS = float32(kubeAPIQPS) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why can't we declare it directly as float32? |
||
| restConfig.Burst = kubeAPIBurst | ||
|
|
||
| mgr, err := ctrl.NewManager(restConfig, ctrl.Options{ | ||
| Scheme: scheme, | ||
| Metrics: metricsServerOptions, | ||
| HealthProbeBindAddress: probeAddr, | ||
|
|
@@ -132,15 +150,17 @@ func main() { | |
|
|
||
| // Create reconcilers linked to the main controller | ||
| ruleReconciler := &controller.RuleReconciler{ | ||
| Client: mgr.GetClient(), | ||
| Scheme: mgr.GetScheme(), | ||
| Controller: readinessController, | ||
| Client: mgr.GetClient(), | ||
| Scheme: mgr.GetScheme(), | ||
| Controller: readinessController, | ||
| MaxConcurrentReconciles: ruleConcurrentReconciles, | ||
| } | ||
|
|
||
| nodeReconciler := &controller.NodeReconciler{ | ||
| Client: mgr.GetClient(), | ||
| Scheme: mgr.GetScheme(), | ||
| Controller: readinessController, | ||
| Client: mgr.GetClient(), | ||
| Scheme: mgr.GetScheme(), | ||
| Controller: readinessController, | ||
| MaxConcurrentReconciles: nodeConcurrentReconciles, | ||
| } | ||
|
|
||
| // Setup controllers with manager | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that these vars are increasing, I think we can keep them in vars() block outside main for better code organization?