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

Allow override QPS and Burst via flag #1778

Merged
merged 2 commits into from
Oct 7, 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
14 changes: 14 additions & 0 deletions injection/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"flag"
"log"
"math"
"os"
"os/user"
"path/filepath"
Expand All @@ -37,6 +38,9 @@ func ParseAndGetRESTConfigOrDie() *rest.Config {
"The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
kubeconfig = flag.String("kubeconfig", "",
"Path to a kubeconfig. Only required if out-of-cluster.")

burst = flag.Int("kube-api-burst", 0, "Maximum burst for throttle.")
qps = flag.Float64("kube-api-qps", 0, "Maximum QPS to the server from the client.")
)
klog.InitFlags(flag.CommandLine)
flag.Parse()
Expand All @@ -46,6 +50,16 @@ func ParseAndGetRESTConfigOrDie() *rest.Config {
log.Fatal("Error building kubeconfig: ", err)
}

if *burst < 0 {
log.Fatal("Invalid burst value", *burst)
}
if *qps < 0 || *qps > math.MaxFloat32 {
log.Fatal("Invalid QPS value", *qps)
}

cfg.Burst = *burst
cfg.QPS = float32(*qps)

return cfg
}

Expand Down