Skip to content

Commit

Permalink
Split clients for rate limit (#83)
Browse files Browse the repository at this point in the history
* split clients for rate limit

---------

Co-authored-by: Mangirdas <[email protected]>
  • Loading branch information
mjudeikis and mjudeikis authored Sep 8, 2023
1 parent 03864b5 commit 4778713
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,25 @@ func run(
if err != nil {
return err
}
restConfigLeader := rest.CopyConfig(restconfig)
restConfigDynamic := rest.CopyConfig(restconfig)

restconfig.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(float32(cfg.KubeClient.QPS), cfg.KubeClient.Burst)
restConfigLeader.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(float32(cfg.KubeClient.QPS), cfg.KubeClient.Burst)
restConfigDynamic.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(float32(cfg.KubeClient.QPS), cfg.KubeClient.Burst)

helmClient := helm.NewClient(logger, helm.NewChartLoader(), restconfig)

clientset, err := kubernetes.NewForConfig(restconfig)
if err != nil {
return err
}
clientSetLeader, err := kubernetes.NewForConfig(restConfigLeader)
if err != nil {
return err
}

dynamicClient, err := dynamic.NewForConfig(restconfig)
dynamicClient, err := dynamic.NewForConfig(restConfigDynamic)
if err != nil {
return err
}
Expand Down Expand Up @@ -190,7 +199,7 @@ func run(

if cfg.LeaderElection.Enabled {
// Run actions service with leader election. Blocks.
return runWithLeaderElection(ctx, log, clientset, leaderHealthCheck, cfg.LeaderElection, svc.Run)
return runWithLeaderElection(ctx, log, clientSetLeader, leaderHealthCheck, cfg.LeaderElection, svc.Run)
}

// Run action service. Blocks.
Expand Down

0 comments on commit 4778713

Please sign in to comment.