Skip to content

Commit c861f32

Browse files
committed
Set QPS and Burst when impersonating service account
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
1 parent ed06a71 commit c861f32

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

controllers/helmrelease_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func (r *HelmReleaseReconciler) getRESTClientGetter(ctx context.Context, hr v2.H
495495
if len(kubeConfig) == 0 {
496496
return nil, fmt.Errorf("KubeConfig secret '%s' does not contain a 'value' key", secretName)
497497
}
498-
return kube.NewMemoryRESTClientGetter(kubeConfig, hr.GetReleaseNamespace(), impersonateAccount), nil
498+
return kube.NewMemoryRESTClientGetter(kubeConfig, hr.GetReleaseNamespace(), impersonateAccount, r.Config.QPS, r.Config.Burst), nil
499499
}
500500

501501
if r.DefaultServiceAccount != "" || hr.Spec.ServiceAccountName != "" {

internal/kube/client.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ func NewInClusterRESTClientGetter(cfg *rest.Config, namespace string) genericcli
3232
flags.BearerToken = &cfg.BearerToken
3333
flags.CAFile = &cfg.CAFile
3434
flags.Namespace = &namespace
35+
flags.WithDiscoveryBurst(cfg.Burst)
36+
flags.WithDiscoveryQPS(cfg.QPS)
3537
if sa := cfg.Impersonate.UserName; sa != "" {
3638
flags.Impersonate = &sa
3739
}
@@ -45,13 +47,17 @@ type MemoryRESTClientGetter struct {
4547
kubeConfig []byte
4648
namespace string
4749
impersonateAccount string
50+
qps float32
51+
burst int
4852
}
4953

50-
func NewMemoryRESTClientGetter(kubeConfig []byte, namespace string, impersonateAccount string) genericclioptions.RESTClientGetter {
54+
func NewMemoryRESTClientGetter(kubeConfig []byte, namespace string, impersonateAccount string, qps float32, burst int) genericclioptions.RESTClientGetter {
5155
return &MemoryRESTClientGetter{
5256
kubeConfig: kubeConfig,
5357
namespace: namespace,
5458
impersonateAccount: impersonateAccount,
59+
qps: qps,
60+
burst: burst,
5561
}
5662
}
5763

@@ -76,10 +82,8 @@ func (c *MemoryRESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryI
7682
config.Impersonate = rest.ImpersonationConfig{UserName: c.impersonateAccount}
7783
}
7884

79-
// The more groups you have, the more discovery requests you need to make.
80-
// given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests
81-
// double it just so we don't end up here again for a while. This config is only used for discovery.
82-
config.Burst = 100
85+
config.QPS = c.qps
86+
config.Burst = c.burst
8387

8488
discoveryClient, _ := discovery.NewDiscoveryClientForConfig(config)
8589
return memory.NewMemCacheClient(discoveryClient), nil

0 commit comments

Comments
 (0)