Skip to content

Commit

Permalink
Patch CAPI with rate limit arguments (#2464)
Browse files Browse the repository at this point in the history
* Patch CAPI with rate limit arguments

* Fix checksums
  • Loading branch information
vignesh-goutham authored Sep 5, 2023
1 parent 7ad60a6 commit 2d6a095
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 10 deletions.
20 changes: 10 additions & 10 deletions projects/kubernetes-sigs/cluster-api/CHECKSUMS
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
eb7d1ae1ffca031f78a55c27585559290c60ae66af04a8e97b2c892cd56f4a3c _output/bin/cluster-api/linux-amd64/cluster-api-provider-docker-manager
629d593a733b07f6d8d4e7b259c7d5f7e9f6907e8551c5f07984eaf4ae7ae5bd _output/bin/cluster-api/linux-amd64/clusterctl
c180ba35ebc20a9ef9373f166ab04e20444c76a517e908d4db5ad41207ebffec _output/bin/cluster-api/linux-amd64/kubeadm-bootstrap-manager
e59b086e704ec9e5977ca7b53139e02b498eb7fb334ab57a3e58029a0f3d6f59 _output/bin/cluster-api/linux-amd64/kubeadm-control-plane-manager
02a7ff7d6fad94c4dcdf7caebdd99ab782c496a72332db3202949553a4c97bae _output/bin/cluster-api/linux-amd64/manager
af4bba2dec68e10a9a0fee3a81da79f862ac79df9c7fa8c2cdac9af5830d3767 _output/bin/cluster-api/linux-arm64/cluster-api-provider-docker-manager
6d1efa56b11cc4e3002d847a5e1898044135e7945b5e403a04c67948633626e3 _output/bin/cluster-api/linux-arm64/clusterctl
28d8a1ea618ca04b5ff22e3f70e6822f8079302772aa9004210c8ab00a9fba02 _output/bin/cluster-api/linux-arm64/kubeadm-bootstrap-manager
08162b8c92f29fb171b11810df7a1657f8bc341df2b4594a352ae95f56d0297d _output/bin/cluster-api/linux-arm64/kubeadm-control-plane-manager
710821982667b47b09bd89621a79d4a703a6fa1e364a92def054f6336bc23990 _output/bin/cluster-api/linux-arm64/manager
c274617a04555d1f2cc504188ef2964dde8c89a1751c2acd56954837db85f42e _output/bin/cluster-api/linux-amd64/cluster-api-provider-docker-manager
6afd6a06651f5cb46d2b8e92becb73dd952ea4fac34fe9de78a284dbab514c20 _output/bin/cluster-api/linux-amd64/clusterctl
8a6f824ae5bf41a9f9f353445099483af3ba983d5807d817c0893e2de3a6f62a _output/bin/cluster-api/linux-amd64/kubeadm-bootstrap-manager
9e1230bb9ca76899f259c6f23c69db719f3f229d77b01468223a0d7150f3be7e _output/bin/cluster-api/linux-amd64/kubeadm-control-plane-manager
339f3ca34088edbb4f03cd3d4851372e213cd82e17951cf9f2ed55e1d12b437c _output/bin/cluster-api/linux-amd64/manager
12c19f80ff004b94e9ceddb3ab37a821bc380ffaf6096732369887fb90457d19 _output/bin/cluster-api/linux-arm64/cluster-api-provider-docker-manager
c2b225c13ca11ce5e1c26aca84ae834f0a427b99529a97c8321073dded41277d _output/bin/cluster-api/linux-arm64/clusterctl
cb51f74b3d3c19237c25b6359965e24e420207b1d60e312bbaf93377d90afac3 _output/bin/cluster-api/linux-arm64/kubeadm-bootstrap-manager
24e5697b9f7f885687e2c1115b0f02bb046a9bcf3f464784d4520a351a2be322 _output/bin/cluster-api/linux-arm64/kubeadm-control-plane-manager
3c980bb5da050c081dc6d41abdbefffb07bc82bf01ad5eb82e9716eb5077feeb _output/bin/cluster-api/linux-arm64/manager
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)

0 comments on commit 2d6a095

Please sign in to comment.