From 0980e2f3bad3e20a35de31deedf73d1b9af7369d Mon Sep 17 00:00:00 2001 From: Joachim Bartosik Date: Thu, 28 Dec 2023 16:38:31 +0000 Subject: [PATCH] Restore flags for setting QPS limit in CA Partially undo #6274. I noticed that with this change CA get rate limited and slows down significantly (especially during large scale downs). --- cluster-autoscaler/config/autoscaling_options.go | 4 ++++ cluster-autoscaler/main.go | 6 ++++-- cluster-autoscaler/utils/kubernetes/client.go | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cluster-autoscaler/config/autoscaling_options.go b/cluster-autoscaler/config/autoscaling_options.go index 260845c78ed0..833a3a8b1478 100644 --- a/cluster-autoscaler/config/autoscaling_options.go +++ b/cluster-autoscaler/config/autoscaling_options.go @@ -291,4 +291,8 @@ type KubeClientOptions struct { KubeConfigPath string // APIContentType specifies type of requests sent to APIServer. APIContentType string + // Burst setting for kubernetes client + KubeClientBurst int + // QPS setting for kubernetes client + KubeClientQPS float32 } diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index c69e7a39ef09..3201221f08de 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -103,8 +103,8 @@ var ( kubernetes = flag.String("kubernetes", "", "Kubernetes master location. Leave blank for default") kubeConfigFile = flag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information.") kubeAPIContentType = flag.String("kube-api-content-type", "application/vnd.kubernetes.protobuf", "Content type of requests sent to apiserver.") - _ = flag.Int("kube-client-burst", rest.DefaultBurst, "Burst value for kubernetes client. (Deprecated, relay on APF for rate limiting)") - _ = flag.Float64("kube-client-qps", float64(rest.DefaultQPS), "QPS value for kubernetes client. (Deprecated, relay on APF for rate limiting)") + kubeClientBurst = flag.Int("kube-client-burst", rest.DefaultBurst, "Burst value for kubernetes client. (Deprecated, relay on APF for rate limiting)") + kubeClientQPS = flag.Float64("kube-client-qps", float64(rest.DefaultQPS), "QPS value for kubernetes client. (Deprecated, relay on APF for rate limiting)") cloudConfig = flag.String("cloud-config", "", "The path to the cloud provider configuration file. Empty string for no configuration file.") namespace = flag.String("namespace", "kube-system", "Namespace in which cluster-autoscaler run.") enforceNodeGroupMinSize = flag.Bool("enforce-node-group-min-size", false, "Should CA scale up the node group to the configured min size if needed.") @@ -442,6 +442,8 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter // Create basic config from flags. autoscalingOptions := createAutoscalingOptions() + autoscalingOptions.KubeClientOpts.KubeClientBurst = int(*kubeClientBurst) + autoscalingOptions.KubeClientOpts.KubeClientQPS = float32(*kubeClientQPS) kubeClient := kube_util.CreateKubeClient(autoscalingOptions.KubeClientOpts) // Informer transform to trim ManagedFields for memory efficiency. diff --git a/cluster-autoscaler/utils/kubernetes/client.go b/cluster-autoscaler/utils/kubernetes/client.go index f7f1dcc45fb7..a86d452e86e1 100644 --- a/cluster-autoscaler/utils/kubernetes/client.go +++ b/cluster-autoscaler/utils/kubernetes/client.go @@ -62,6 +62,8 @@ func getKubeConfig(opts config.KubeClientOptions) *rest.Config { } } + kubeConfig.QPS = opts.KubeClientQPS + kubeConfig.Burst = opts.KubeClientBurst kubeConfig.ContentType = opts.APIContentType return kubeConfig