From d97c271b84364a062d9ad611a18f0e478d59780c Mon Sep 17 00:00:00 2001
From: Demch1k <demch1k.mid@gmail.com>
Date: Mon, 23 Dec 2024 12:53:27 +0500
Subject: [PATCH] Add abitility to set QPS and Burst limits for api client
 (#2667)

* Add abitility to set QPS and Burst limits for api client

---------

Co-authored-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
---
 cmd/main.go       | 5 +++++
 pkg/spec/types.go | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/cmd/main.go b/cmd/main.go
index 0b48ac86..adbf0cce 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -35,6 +35,8 @@ func init() {
 	flag.BoolVar(&outOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.")
 	flag.BoolVar(&config.NoDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.")
 	flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API")
+	flag.IntVar(&config.KubeQPS, "kubeqps", 10, "Kubernetes api requests per second.")
+	flag.IntVar(&config.KubeBurst, "kubeburst", 20, "Kubernetes api requests burst limit.")
 	flag.Parse()
 
 	config.EnableJsonLogging = os.Getenv("ENABLE_JSON_LOGGING") == "true"
@@ -83,6 +85,9 @@ func main() {
 		log.Fatalf("couldn't get REST config: %v", err)
 	}
 
+	config.RestConfig.QPS = float32(config.KubeQPS)
+	config.RestConfig.Burst = config.KubeBurst
+
 	c := controller.NewController(&config, "")
 
 	c.Run(stop, wg)
diff --git a/pkg/spec/types.go b/pkg/spec/types.go
index cfa293e1..d727aee4 100644
--- a/pkg/spec/types.go
+++ b/pkg/spec/types.go
@@ -122,6 +122,9 @@ type ControllerConfig struct {
 	IgnoredAnnotations   []string
 
 	EnableJsonLogging bool
+
+	KubeQPS   int
+	KubeBurst int
 }
 
 // cached value for the GetOperatorNamespace
-- 
GitLab