diff --git a/charts/gha-runner-scale-set-controller/templates/deployment.yaml b/charts/gha-runner-scale-set-controller/templates/deployment.yaml index 877ab984..b0283862 100644 --- a/charts/gha-runner-scale-set-controller/templates/deployment.yaml +++ b/charts/gha-runner-scale-set-controller/templates/deployment.yaml @@ -85,6 +85,12 @@ spec: {{- range .Values.flags.excludeLabelPropagationPrefixes }} - "--exclude-label-propagation-prefix={{ . }}" {{- end }} + {{- with .Values.flags.k8sClientRateLimiterQPS }} + - "--k8s-client-rate-limiter-qps={{ . }}" + {{- end }} + {{- with .Values.flags.k8sClientRateLimiterBurst }} + - "--k8s-client-rate-limiter-burst={{ . }}" + {{- end }} command: - "/manager" {{- with .Values.metrics }} diff --git a/charts/gha-runner-scale-set-controller/values.yaml b/charts/gha-runner-scale-set-controller/values.yaml index e96ffdda..c96e5abe 100644 --- a/charts/gha-runner-scale-set-controller/values.yaml +++ b/charts/gha-runner-scale-set-controller/values.yaml @@ -135,3 +135,7 @@ flags: ## Labels that match prefix specified in the list are excluded from propagation. # excludeLabelPropagationPrefixes: # - "argocd.argoproj.io/instance" + + ## Defines the K8s client rate limiter parameters. + # k8sClientRateLimiterQPS: 20 + # k8sClientRateLimiterBurst: 30 diff --git a/main.go b/main.go index a7da63a6..61b68a9e 100644 --- a/main.go +++ b/main.go @@ -105,6 +105,9 @@ func main() { opts = actionsgithubcom.OptionsWithDefault() commonRunnerLabels commaSeparatedStringSlice + + k8sClientRateLimiterQPS int + k8sClientRateLimiterBurst int ) var c github.Config err = envconfig.Process("github", &c) @@ -148,6 +151,8 @@ func main() { flag.BoolVar(&autoScalingRunnerSetOnly, "auto-scaling-runner-set-only", false, "Make controller only reconcile AutoRunnerScaleSet object.") flag.StringVar(&updateStrategy, "update-strategy", "immediate", `Resources reconciliation strategy on upgrade with running/pending jobs. Valid values are: "immediate", "eventual". Defaults to "immediate".`) flag.Var(&autoScalerImagePullSecrets, "auto-scaler-image-pull-secrets", "The default image-pull secret name for auto-scaler listener container.") + flag.IntVar(&k8sClientRateLimiterQPS, "k8s-client-rate-limiter-qps", 20, "The QPS value of the K8s client rate limiter.") + flag.IntVar(&k8sClientRateLimiterBurst, "k8s-client-rate-limiter-burst", 30, "The burst value of the K8s client rate limiter.") flag.Parse() runnerPodDefaults.RunnerImagePullSecrets = runnerImagePullSecrets @@ -219,7 +224,11 @@ func main() { }) } - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + cfg := ctrl.GetConfigOrDie() + cfg.QPS = float32(k8sClientRateLimiterQPS) + cfg.Burst = k8sClientRateLimiterBurst + + mgr, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme, Metrics: metricsserver.Options{ BindAddress: metricsAddr,