Skip to content

Commit a0d774c

Browse files
committed
⚠️ Config: Disable client-side ratelimiter by default
Sig-Apimachinery recommends [disabling the client-side ratelimiter][0] and rely on API priority and fairness instead for any [Kubernetes version >= 1.22][1]. Update our config getters to do that. 0: https://kubernetes.slack.com/archives/C0EG7JC6T/p1680889646346859?thread_ts=1680791299.631439&cid=C0EG7JC6T 1: https://kubernetes.slack.com/archives/C0EG7JC6T/p1680892224956789?thread_ts=1680791299.631439&cid=C0EG7JC6T
1 parent 5e8256e commit a0d774c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

pkg/client/config/config.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func RegisterFlags(fs *flag.FlagSet) {
6161
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
6262
// in cluster and use the cluster provided kubeconfig.
6363
//
64+
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
65+
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
66+
//
6467
// It also applies saner defaults for QPS and burst based on the Kubernetes
6568
// controller manager defaults (20 QPS, 30 burst)
6669
//
@@ -81,6 +84,9 @@ func GetConfig() (*rest.Config, error) {
8184
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
8285
// in cluster and use the cluster provided kubeconfig.
8386
//
87+
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
88+
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
89+
//
8490
// It also applies saner defaults for QPS and burst based on the Kubernetes
8591
// controller manager defaults (20 QPS, 30 burst)
8692
//
@@ -99,10 +105,7 @@ func GetConfigWithContext(context string) (*rest.Config, error) {
99105
return nil, err
100106
}
101107
if cfg.QPS == 0.0 {
102-
cfg.QPS = 20.0
103-
}
104-
if cfg.Burst == 0 {
105-
cfg.Burst = 30
108+
cfg.QPS = -1
106109
}
107110
return cfg, nil
108111
}
@@ -170,6 +173,9 @@ func loadConfigWithContext(apiServerURL string, loader clientcmd.ClientConfigLoa
170173
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
171174
// in cluster and use the cluster provided kubeconfig.
172175
//
176+
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
177+
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
178+
//
173179
// Will log an error and exit if there is an error creating the rest.Config.
174180
func GetConfigOrDie() *rest.Config {
175181
config, err := GetConfig()

pkg/client/config/config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ var _ = Describe("Config", func() {
7272
cfg, err := GetConfigWithContext(tc.context)
7373
Expect(err).NotTo(HaveOccurred())
7474
Expect(cfg.Host).To(Equal(tc.wantHost))
75+
Expect(cfg.QPS).To(Equal(float32(-1)))
7576
})
7677
}
7778
}
@@ -82,8 +83,8 @@ var _ = Describe("Config", func() {
8283
Expect(err).NotTo(HaveOccurred())
8384

8485
cfg, err := GetConfigWithContext("")
85-
Expect(cfg).To(BeNil())
8686
Expect(err).To(HaveOccurred())
87+
Expect(cfg).To(BeNil())
8788
})
8889
})
8990

0 commit comments

Comments
 (0)