Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose settings for RateLimiter in kubernetes client #120

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type KubernetesClient interface {

WithContextName(contextName string)
WithConfigPath(configPath string)
WithRateLimiterSettings(qps float32, burst int)

Init() error

Expand Down Expand Up @@ -72,6 +73,8 @@ type kubernetesClient struct {
configPath string
defaultNamespace string
dynamicClient dynamic.Interface
qps float32
burst int
}

func (c *kubernetesClient) WithContextName(name string) {
Expand All @@ -82,6 +85,11 @@ func (c *kubernetesClient) WithConfigPath(path string) {
c.configPath = path
}

func (c *kubernetesClient) WithRateLimiterSettings(qps float32, burst int) {
c.qps = qps
c.burst = burst
}

func (c *kubernetesClient) DefaultNamespace() string {
return c.defaultNamespace
}
Expand Down Expand Up @@ -111,6 +119,8 @@ func (c *kubernetesClient) Init() error {
err = fmt.Errorf("out-of-cluster config error: %v, in-cluster config error: %v", outOfClusterErr, err)
logEntry.Errorf("configuration problems: %s", err)
return err
} else {
return fmt.Errorf("in-cluster config is not found")
}
} else {
logEntry.Errorf("in-cluster problem: %s", err)
Expand All @@ -122,13 +132,18 @@ func (c *kubernetesClient) Init() error {
if outOfClusterErr != nil {
logEntry.Errorf("out-of-cluster problem: %s", outOfClusterErr)
return outOfClusterErr
} else {
return fmt.Errorf("no kubernetes client config found")
}
}
configType = "in-cluster"
}

c.defaultNamespace = defaultNs

config.QPS = c.qps
config.Burst = c.burst

c.Interface, err = kubernetes.NewForConfig(config)
if err != nil {
logEntry.Errorf("configuration problem: %s", err)
Expand Down