Skip to content

Commit a82afb4

Browse files
committed
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.
1 parent 095c4a4 commit a82afb4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/client/config/config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func init() {
4848
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
4949
// in cluster and use the cluster provided kubeconfig.
5050
//
51+
// It also applies saner defaults for QPS and burst based on the Kubernetes
52+
// controller manager defaults (20 QPS, 30 burst)
53+
//
5154
// Config precedence
5255
//
5356
// * --kubeconfig flag pointing at a file
@@ -58,6 +61,21 @@ func init() {
5861
//
5962
// * $HOME/.kube/config if exists
6063
func GetConfig() (*rest.Config, error) {
64+
cfg, err := loadConfig()
65+
if err != nil {
66+
return nil, err
67+
}
68+
69+
if cfg.QPS == 0.0 {
70+
cfg.QPS = 20.0
71+
cfg.Burst = 30.0
72+
}
73+
74+
return cfg, nil
75+
}
76+
77+
// loadConfig loads a REST Config as per the rules specified in GetConfig
78+
func loadConfig() (*rest.Config, error) {
6179
// If a flag is specified with the config location, use that
6280
if len(kubeconfig) > 0 {
6381
return clientcmd.BuildConfigFromFlags(apiServerURL, kubeconfig)

0 commit comments

Comments
 (0)