From d5b46578acbfc1c032cd66b97f3212ac691dd2af Mon Sep 17 00:00:00 2001 From: Paul Laffitte Date: Mon, 19 Jun 2023 16:29:30 +0200 Subject: [PATCH] fix(proxy): lazy discovery of rest mapping to avoid throttling at start --- cmd/proxy/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 4a5853b8..75ddc2c1 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -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(),