From 1817814eb2f352513a86b34bd78e9e9315826cb8 Mon Sep 17 00:00:00 2001 From: George Angel Date: Fri, 1 Nov 2024 17:34:49 +1000 Subject: [PATCH] Allow higher qps and burst for the kube client (#84) With large number of Nodes we can fire a lot of simultaneous reqs, since they are all going through this app, we need to allow higher qps. --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 544c03c..cc08fe9 100644 --- a/main.go +++ b/main.go @@ -429,9 +429,10 @@ func nodeHandler(w http.ResponseWriter, r *http.Request, kubeClient *kubernetes. h.ServeHTTP(w, r) } -// newKubeClient returns a Kubernetes client (clientset) from the supplied -// kubeconfig path, the KUBECONFIG environment variable, the default config file -// location ($HOME/.kube/config) or from the in-cluster service account environment. +// newKubeClient returns a Kubernetes client (clientset) with configurable +// rate limits from a supplied kubeconfig path, the KUBECONFIG environment variable, +// the default config file location ($HOME/.kube/config), or from the in-cluster +// service account environment. func newKubeClient(path string) (*kubernetes.Clientset, error) { loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() if path != "" { @@ -448,6 +449,10 @@ func newKubeClient(path string) (*kubernetes.Clientset, error) { return nil, err } + // Set rate limits to reduce client-side throttling + config.QPS = 100 + config.Burst = 200 + return kubernetes.NewForConfig(config) }