Skip to content

Commit

Permalink
Default REST Config QPS to match KCM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DirectXMan12 committed Mar 19, 2019
1 parent 890cbf4 commit ddf6abf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit ddf6abf

Please sign in to comment.