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(client): kube-api timeout requests #627

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions runtime/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
const (
flagQPS = "kube-api-qps"
flagBurst = "kube-api-burst"
flagTimeout = "kube-api-timeout"
)

// Options contains the runtime configuration for a Kubernetes client.
Expand All @@ -56,6 +57,9 @@ type Options struct {

// Burst indicates the maximum burst queries-per-second of requests sent to the Kubernetes API, defaults to 300.
Burst int

// The maximum length of time to wait before giving up on a server request. A value of zero means no timeout.
Timeout time.Duration
}

// BindFlags will parse the given pflag.FlagSet for Kubernetes client option flags and set the Options accordingly.
Expand All @@ -64,6 +68,8 @@ func (o *Options) BindFlags(fs *pflag.FlagSet) {
"The maximum queries-per-second of requests sent to the Kubernetes API.")
fs.IntVar(&o.Burst, flagBurst, 300,
"The maximum burst queries-per-second of requests sent to the Kubernetes API.")
fs.DurationVar(&o.Timeout, flagTimeout, 0,
"The maximum length of time to wait before giving up on a server request. A value of zero means no timeout.")
}

// GetConfigOrDie wraps ctrl.GetConfigOrDie and checks if the Kubernetes apiserver
Expand All @@ -82,6 +88,7 @@ func GetConfigOrDie(opts Options) *rest.Config {
}
config.QPS = opts.QPS
config.Burst = opts.Burst
config.Timeout = opts.Timeout
return config
}

Expand Down