Skip to content

Commit

Permalink
configurable client qps and burst
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Aug 14, 2024
1 parent f3fa2b8 commit 7a74cbf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
Expand Down Expand Up @@ -68,6 +69,8 @@ var (
printDefaults = flag.Bool("printDefaults", false, "print all variables with their default values and exit")
printFormat = flag.String("printFormat", "table", "output format for --printDefaults. Can be table, json, yaml or list")
promCRDResyncPeriod = flag.Duration("controller.prometheusCRD.resyncPeriod", 0, "Configures resync period for prometheus CRD converter. Disabled by default")
clientQPS = flag.Int("client.qps", 5, "defines K8s client QPS")
clientBurst = flag.Int("client.burst", 10, "defines K8s client burst")
wasCacheSynced = uint32(0)
)

Expand Down Expand Up @@ -133,7 +136,10 @@ func RunManager(ctx context.Context) error {
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
config := ctrl.GetConfigOrDie()
config.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(float32(*clientQPS), *clientBurst)

mgr, err := ctrl.NewManager(config, ctrl.Options{
Logger: ctrl.Log.WithName("manager"),
Scheme: scheme,
Metrics: metricsserver.Options{BindAddress: *metricsBindAddress},
Expand Down

0 comments on commit 7a74cbf

Please sign in to comment.