From ddf6abf1a0c7b4871fcc4b346b1a3ba2bc93926b Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Tue, 19 Mar 2019 15:59:19 -0700 Subject: [PATCH] Default REST Config QPS to match KCM This defaults the loaded REST Config QPS to 20 (burst 30), which matches what the kube controller manager has. The defaults of 5 and 10 (respectively) are pretty slow, especially since they're shared across multiple controllers. --- pkg/client/config/config.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/client/config/config.go b/pkg/client/config/config.go index 0153b5eea8..8d022c5cfa 100644 --- a/pkg/client/config/config.go +++ b/pkg/client/config/config.go @@ -48,6 +48,9 @@ func init() { // If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running // in cluster and use the cluster provided kubeconfig. // +// It also applies saner defaults for QPS and burst based on the Kubernetes +// controller manager defaults (20 QPS, 30 burst) +// // Config precedence // // * --kubeconfig flag pointing at a file @@ -58,6 +61,21 @@ func init() { // // * $HOME/.kube/config if exists func GetConfig() (*rest.Config, error) { + cfg, err := loadConfig() + if err != nil { + return nil, err + } + + if cfg.QPS == 0.0 { + cfg.QPS = 20.0 + cfg.Burst = 30.0 + } + + return cfg, nil +} + +// loadConfig loads a REST Config as per the rules specified in GetConfig +func loadConfig() (*rest.Config, error) { // If a flag is specified with the config location, use that if len(kubeconfig) > 0 { return clientcmd.BuildConfigFromFlags(apiServerURL, kubeconfig)