Skip to content

Commit

Permalink
Allow override QPS and Burst via flag (#1778)
Browse files Browse the repository at this point in the history
* Allow override QPS and Burst via flag.

Add `--kube-api-qps` and `--kube-api-burst` command-line flags
to control client QPS and Burst respectively.

The default value is set to 0 to keep backward compatibility.

Signed-off-by: Pierangelo Di Pilato <[email protected]>

* Inline validation functions

Signed-off-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
pierDipi committed Oct 7, 2020
1 parent 4c07e18 commit 1a4c99a
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit 1a4c99a

Please sign in to comment.