Allow changing discovery QPS with cli-runtime

This commit is contained in:
Maciej Szulik 2021-11-16 22:27:33 +01:00
parent e944d2c365
commit 2fe968deb6
No known key found for this signature in database
GPG Key ID: F15E55D276FA84C4
2 changed files with 11 additions and 1 deletions

View File

@ -120,6 +120,9 @@ type ConfigFlags struct {
// Allows increasing burst used for discovery, this is useful
// in clusters with many registered resources
discoveryBurst int
// Allows increasing qps used for discovery, this is useful
// in clusters with many registered resources
discoveryQPS float32
}
// ToRESTConfig implements RESTClientGetter.
@ -269,6 +272,7 @@ func (f *ConfigFlags) toDiscoveryClient() (discovery.CachedDiscoveryInterface, e
}
config.Burst = f.discoveryBurst
config.QPS = f.discoveryQPS
cacheDir := defaultCacheDir
@ -393,6 +397,12 @@ func (f *ConfigFlags) WithDiscoveryBurst(discoveryBurst int) *ConfigFlags {
return f
}
// WithDiscoveryBurst sets the RESTClient burst for discovery.
func (f *ConfigFlags) WithDiscoveryQPS(discoveryQPS float32) *ConfigFlags {
f.discoveryQPS = discoveryQPS
return f
}
// WithWrapConfigFn allows providing a wrapper function for the client Config.
func (f *ConfigFlags) WithWrapConfigFn(wrapConfigFn func(*rest.Config) *rest.Config) *ConfigFlags {
f.WrapConfigFn = wrapConfigFn

View File

@ -294,7 +294,7 @@ func NewKubectlCommand(o KubectlOptions) *cobra.Command {
kubeConfigFlags := o.ConfigFlags
if kubeConfigFlags == nil {
kubeConfigFlags = genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag().WithDiscoveryBurst(300)
kubeConfigFlags = genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag().WithDiscoveryBurst(300).WithDiscoveryQPS(50.0)
}
kubeConfigFlags.AddFlags(flags)
matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(kubeConfigFlags)