Skip to content

Commit

Permalink
fix(proxy): lazy discovery of rest mapping to avoid throttling at start
Browse files Browse the repository at this point in the history
  • Loading branch information
paullaffitte authored and Nicolasgouze committed Sep 6, 2023
1 parent 31b0f65 commit d5b4657
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ func main() {
panic(err)
}

restMapper, err := apiutil.NewDynamicRESTMapper(config, apiutil.WithLazyDiscovery)
if err != nil {
panic(err)
}

// Set rate limiter only if both QPS and burst are set
if rateLimitQPS > 0 && rateLimitBurst > 0 {
klog.Infof("setting Kubernetes API rate limiter to %d QPS and %d burst", rateLimitQPS, rateLimitBurst)
config.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(float32(rateLimitQPS), rateLimitBurst)
}
restMapper, err := apiutil.NewDynamicRESTMapper(config, apiutil.WithLazyDiscovery)
if err != nil {
panic(err)
}

k8sClient, err := client.New(config, client.Options{
Scheme: scheme.NewScheme(),
Expand Down

0 comments on commit d5b4657

Please sign in to comment.