-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bump-capi-1.5.1
- Loading branch information
Showing
1 changed file
with
183 additions
and
0 deletions.
There are no files selected for viewing
183 changes: 183 additions & 0 deletions
183
...ects/kubernetes-sigs/cluster-api/patches/0037-Add-flags-for-configuring-rate-limits.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
From ba34136c11580c8cba752a3dd1a408cd8b2a7769 Mon Sep 17 00:00:00 2001 | ||
From: Lennart Jern <[email protected]> | ||
Date: Thu, 27 Apr 2023 14:03:23 +0300 | ||
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20flags=20for=20configuring=20r?= | ||
=?UTF-8?q?ate=20limits?= | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
All the controllers have built-in rate limits. They throttle themselves | ||
if they hit this limit. So far it has not been possible to configure | ||
these limits. This commit adds flags to the controllers for setting both | ||
the QPS and the burst for the rate limits. The default remains the same | ||
as before (20 QPS, 30 burst). | ||
|
||
New flags (for each controller, including CAPD): | ||
|
||
--kube-api-qps | ||
--kube-api-burst | ||
|
||
Also adds .devcontainer to .gitignore. | ||
|
||
Signed-off-by: Vignesh Goutham Ganesh <[email protected]> | ||
--- | ||
.gitignore | 3 +++ | ||
bootstrap/kubeadm/main.go | 10 ++++++++++ | ||
controlplane/kubeadm/main.go | 10 ++++++++++ | ||
main.go | 10 ++++++++++ | ||
test/infrastructure/docker/main.go | 8 ++++++++ | ||
5 files changed, 41 insertions(+) | ||
|
||
diff --git a/.gitignore b/.gitignore | ||
index 35833619a..687dead39 100644 | ||
--- a/.gitignore | ||
+++ b/.gitignore | ||
@@ -89,3 +89,6 @@ tmp | ||
|
||
# asdf (not a typo! ;) used to manage multiple versions of tools | ||
.tool-versions | ||
+ | ||
+# Development container configurations (https://containers.dev/) | ||
+.devcontainer | ||
diff --git a/bootstrap/kubeadm/main.go b/bootstrap/kubeadm/main.go | ||
index cbbd39495..9a0d26c92 100644 | ||
--- a/bootstrap/kubeadm/main.go | ||
+++ b/bootstrap/kubeadm/main.go | ||
@@ -84,6 +84,8 @@ var ( | ||
profilerAddress string | ||
kubeadmConfigConcurrency int | ||
syncPeriod time.Duration | ||
+ restConfigQPS float32 | ||
+ restConfigBurst int | ||
webhookPort int | ||
webhookCertDir string | ||
healthAddr string | ||
@@ -123,6 +125,12 @@ func InitFlags(fs *pflag.FlagSet) { | ||
fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute, | ||
"The minimum interval at which watched resources are reconciled (e.g. 15m)") | ||
|
||
+ fs.Float32Var(&restConfigQPS, "kube-api-qps", 20, | ||
+ "Maximum queries per second from the controller client to the Kubernetes API server. Defaults to 20") | ||
+ | ||
+ fs.IntVar(&restConfigBurst, "kube-api-burst", 30, | ||
+ "Maximum number of queries that should be allowed in one burst from the controller client to the Kubernetes API server. Default 30") | ||
+ | ||
fs.DurationVar(&tokenTTL, "bootstrap-token-ttl", kubeadmbootstrapcontrollers.DefaultTokenTTL, | ||
"The amount of time the bootstrap token will be valid") | ||
|
||
@@ -167,6 +175,8 @@ func main() { | ||
} | ||
|
||
restConfig := ctrl.GetConfigOrDie() | ||
+ restConfig.QPS = restConfigQPS | ||
+ restConfig.Burst = restConfigBurst | ||
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent("cluster-api-kubeadm-bootstrap-manager") | ||
|
||
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions) | ||
diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go | ||
index 36b2e745a..1dd0599e2 100644 | ||
--- a/controlplane/kubeadm/main.go | ||
+++ b/controlplane/kubeadm/main.go | ||
@@ -89,6 +89,8 @@ var ( | ||
profilerAddress string | ||
kubeadmControlPlaneConcurrency int | ||
syncPeriod time.Duration | ||
+ restConfigQPS float32 | ||
+ restConfigBurst int | ||
webhookPort int | ||
webhookCertDir string | ||
healthAddr string | ||
@@ -129,6 +131,12 @@ func InitFlags(fs *pflag.FlagSet) { | ||
fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute, | ||
"The minimum interval at which watched resources are reconciled (e.g. 15m)") | ||
|
||
+ fs.Float32Var(&restConfigQPS, "kube-api-qps", 20, | ||
+ "Maximum queries per second from the controller client to the Kubernetes API server. Defaults to 20") | ||
+ | ||
+ fs.IntVar(&restConfigBurst, "kube-api-burst", 30, | ||
+ "Maximum number of queries that should be allowed in one burst from the controller client to the Kubernetes API server. Default 30") | ||
+ | ||
fs.StringVar(&watchFilterValue, "watch-filter", "", | ||
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel)) | ||
|
||
@@ -176,6 +184,8 @@ func main() { | ||
} | ||
|
||
restConfig := ctrl.GetConfigOrDie() | ||
+ restConfig.QPS = restConfigQPS | ||
+ restConfig.Burst = restConfigBurst | ||
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent("cluster-api-kubeadm-control-plane-manager") | ||
|
||
tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions) | ||
diff --git a/main.go b/main.go | ||
index f93e58361..1efcb3aec 100644 | ||
--- a/main.go | ||
+++ b/main.go | ||
@@ -99,6 +99,8 @@ var ( | ||
clusterResourceSetConcurrency int | ||
machineHealthCheckConcurrency int | ||
syncPeriod time.Duration | ||
+ restConfigQPS float32 | ||
+ restConfigBurst int | ||
webhookPort int | ||
webhookCertDir string | ||
healthAddr string | ||
@@ -192,6 +194,12 @@ func InitFlags(fs *pflag.FlagSet) { | ||
fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute, | ||
"The minimum interval at which watched resources are reconciled (e.g. 15m)") | ||
|
||
+ fs.Float32Var(&restConfigQPS, "kube-api-qps", 20, | ||
+ "Maximum queries per second from the controller client to the Kubernetes API server. Defaults to 20") | ||
+ | ||
+ fs.IntVar(&restConfigBurst, "kube-api-burst", 30, | ||
+ "Maximum number of queries that should be allowed in one burst from the controller client to the Kubernetes API server. Default 30") | ||
+ | ||
fs.IntVar(&webhookPort, "webhook-port", 9443, | ||
"Webhook Server port") | ||
|
||
@@ -231,6 +239,8 @@ func main() { | ||
} | ||
|
||
restConfig := ctrl.GetConfigOrDie() | ||
+ restConfig.QPS = restConfigQPS | ||
+ restConfig.Burst = restConfigBurst | ||
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent("cluster-api-controller-manager") | ||
|
||
minVer := version.MinimumKubernetesVersion | ||
diff --git a/test/infrastructure/docker/main.go b/test/infrastructure/docker/main.go | ||
index 195ded75c..2b4bb432b 100644 | ||
--- a/test/infrastructure/docker/main.go | ||
+++ b/test/infrastructure/docker/main.go | ||
@@ -67,6 +67,8 @@ var ( | ||
profilerAddress string | ||
syncPeriod time.Duration | ||
concurrency int | ||
+ restConfigQPS float32 | ||
+ restConfigBurst int | ||
healthAddr string | ||
webhookPort int | ||
webhookCertDir string | ||
@@ -99,6 +101,10 @@ func initFlags(fs *pflag.FlagSet) { | ||
"Bind address to expose the pprof profiler (e.g. localhost:6060)") | ||
fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute, | ||
"The minimum interval at which watched resources are reconciled (e.g. 15m)") | ||
+ fs.Float32Var(&restConfigQPS, "kube-api-qps", 20, | ||
+ "Maximum queries per second from the controller client to the Kubernetes API server. Defaults to 20") | ||
+ fs.IntVar(&restConfigBurst, "kube-api-burst", 30, | ||
+ "Maximum number of queries that should be allowed in one burst from the controller client to the Kubernetes API server. Default 30") | ||
fs.StringVar(&healthAddr, "health-addr", ":9440", | ||
"The address the health endpoint binds to.") | ||
fs.IntVar(&webhookPort, "webhook-port", 9443, | ||
@@ -139,6 +145,8 @@ func main() { | ||
} | ||
|
||
restConfig := ctrl.GetConfigOrDie() | ||
+ restConfig.QPS = restConfigQPS | ||
+ restConfig.Burst = restConfigBurst | ||
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent("cluster-api-docker-controller-manager") | ||
ctrlOptions := ctrl.Options{ | ||
Scheme: myscheme, | ||
-- | ||
2.39.2 (Apple Git-143) | ||
|