Skip to content

Commit cf250a8

Browse files
authored
Merge pull request #121 from whitebear009/qps-and-burst
add qps/burst flag for k8s client, and provide method to hide these flags
2 parents e61b02b + 256b891 commit cf250a8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pkg/cmd/builder.go

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

7276
// FlagSet is the flagset to add flags to.
7377
// It defaults to the normal CommandLine flags
@@ -107,7 +111,9 @@ func (b *AdapterBase) InstallFlags() {
107111
"kubeconfig file pointing at the 'core' kubernetes server with enough rights to list "+
108112
"any described objects")
109113
b.FlagSet.DurationVar(&b.DiscoveryInterval, "discovery-interval", b.DiscoveryInterval,
110-
"interval at which to refresh API discovery information")
114+
"Interval at which to refresh API discovery information")
115+
b.FlagSet.Float32Var(&b.ClientQPS, "client-qps", rest.DefaultQPS, "Maximum QPS for client-side throttle")
116+
b.FlagSet.IntVar(&b.ClientBurst, "client-burst", rest.DefaultBurst, "Maximum QPS burst for client-side throttle")
111117
})
112118
}
113119

@@ -150,6 +156,13 @@ func (b *AdapterBase) ClientConfig() (*rest.Config, error) {
150156
}
151157
b.clientConfig = clientConfig
152158
}
159+
160+
if b.ClientQPS > 0 {
161+
b.clientConfig.QPS = b.ClientQPS
162+
}
163+
if b.ClientBurst > 0 {
164+
b.clientConfig.Burst = b.ClientBurst
165+
}
153166
return b.clientConfig, nil
154167
}
155168

0 commit comments

Comments
 (0)