Skip to content

Add flags to be able to configure kubernetes client throttling #51

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

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions cmd/app/options/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

type ClientOptions struct {
*genericclioptions.ConfigFlags

KubeClientQPS float32
KubeClientBurst int
}

func NewClientOptions(nfs *cliflag.NamedFlagSets) *ClientOptions {
Expand All @@ -27,6 +30,15 @@ func NewClientOptions(nfs *cliflag.NamedFlagSets) *ClientOptions {

func (c *ClientOptions) AddFlags(fs *pflag.FlagSet) *ClientOptions {
c.ConfigFlags.AddFlags(fs)

// Extra flags
fs.Float32Var(&c.KubeClientQPS, "kube-client-qps", c.KubeClientQPS, "Sets the QPS on the app "+
"kubernetes client, this will configure throttling on requests sent to the apiserver "+
"(If not set, it will use client default ones)")
fs.IntVar(&c.KubeClientBurst, "kube-client-burst", c.KubeClientBurst, "Sets the burst on the app "+
"kubernetes client, this will configure throttling on requests sent to the apiserver"+
"(If not set, it will use client default ones)")

return c
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ func buildRunCommand(stopCh <-chan struct{}, opts *options.Options) *cobra.Comma
}
}

// Set client throttling settings for Kubernetes clients.
if opts.Client.KubeClientBurst > 0 {
restConfig.Burst = opts.Client.KubeClientBurst
}
if opts.Client.KubeClientQPS > 0 {
restConfig.QPS = opts.Client.KubeClientQPS
}

// Initialise token reviewer if enabled
var tokenReviewer *tokenreview.TokenReview
if opts.App.TokenPassthrough.Enabled {
Expand Down