Skip to content

Commit

Permalink
Set a token bucket rate limiter for Kubernetes client
Browse files Browse the repository at this point in the history
Replaced direct QPS and Burst configuration with a token bucket rate limiter using Kubernetes client-go's flowcontrol package.

Signed-off-by: R.K <ron.kahn@run.ai>
  • Loading branch information
ronk21runai committed Feb 12, 2025
1 parent 91c935f commit 047db1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/training-operator.v1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"errors"
"flag"
"k8s.io/client-go/util/flowcontrol"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -135,8 +136,7 @@ func main() {
}

cfg := ctrl.GetConfigOrDie()
cfg.QPS = float32(clientQps)
cfg.Burst = clientBurst
cfg.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(float32(clientQps), clientBurst)

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Expand Down

0 comments on commit 047db1a

Please sign in to comment.