Skip to content

Commit 572a3d6

Browse files
committed
add qps/burst flag for k8s client
1 parent 41ec178 commit 572a3d6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/cmd/builder.go

+13
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ type AdapterBase struct {
6767
// DiscoveryInterval specifies the interval at which to recheck discovery
6868
// information for the discovery RESTMapper. It's set from a flag.
6969
DiscoveryInterval time.Duration
70+
// ClientQPS specifies the maximum QPS for the client. It's set from a flag.
71+
ClientQPS float32
72+
// ClientBurst specifies the maximum burst for client-side throttle. It's set from a flag.
73+
ClientBurst int
7074

7175
// FlagSet is the flagset to add flags to.
7276
// It defaults to the normal CommandLine flags
@@ -111,6 +115,8 @@ func (b *AdapterBase) InstallFlags() {
111115
"any described objects")
112116
b.FlagSet.DurationVar(&b.DiscoveryInterval, "discovery-interval", b.DiscoveryInterval,
113117
"interval at which to refresh API discovery information")
118+
b.FlagSet.Float32Var(&b.ClientQPS, "client-qps", b.ClientQPS, "maximum QPS for client")
119+
b.FlagSet.IntVar(&b.ClientBurst, "client-burst", b.ClientBurst, "maximum burst for client-side throttle")
114120
})
115121
}
116122

@@ -153,6 +159,13 @@ func (b *AdapterBase) ClientConfig() (*rest.Config, error) {
153159
}
154160
b.clientConfig = clientConfig
155161
}
162+
163+
if b.ClientQPS > 0 {
164+
b.clientConfig.QPS = b.ClientQPS
165+
}
166+
if b.ClientBurst > 0 {
167+
b.clientConfig.Burst = b.ClientBurst
168+
}
156169
return b.clientConfig, nil
157170
}
158171

0 commit comments

Comments
 (0)