Skip to content

Commit 7e04027

Browse files
Link-tfujiwar
andauthored
Make k8s client rate limiter parameters configurable (#3848)
Co-authored-by: Taketoshi Fujiwara <[email protected]>
1 parent 488b095 commit 7e04027

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

charts/gha-runner-scale-set-controller/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ spec:
8585
{{- range .Values.flags.excludeLabelPropagationPrefixes }}
8686
- "--exclude-label-propagation-prefix={{ . }}"
8787
{{- end }}
88+
{{- with .Values.flags.k8sClientRateLimiterQPS }}
89+
- "--k8s-client-rate-limiter-qps={{ . }}"
90+
{{- end }}
91+
{{- with .Values.flags.k8sClientRateLimiterBurst }}
92+
- "--k8s-client-rate-limiter-burst={{ . }}"
93+
{{- end }}
8894
command:
8995
- "/manager"
9096
{{- with .Values.metrics }}

charts/gha-runner-scale-set-controller/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,7 @@ flags:
135135
## Labels that match prefix specified in the list are excluded from propagation.
136136
# excludeLabelPropagationPrefixes:
137137
# - "argocd.argoproj.io/instance"
138+
139+
## Defines the K8s client rate limiter parameters.
140+
# k8sClientRateLimiterQPS: 20
141+
# k8sClientRateLimiterBurst: 30

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func main() {
105105
opts = actionsgithubcom.OptionsWithDefault()
106106

107107
commonRunnerLabels commaSeparatedStringSlice
108+
109+
k8sClientRateLimiterQPS int
110+
k8sClientRateLimiterBurst int
108111
)
109112
var c github.Config
110113
err = envconfig.Process("github", &c)
@@ -148,6 +151,8 @@ func main() {
148151
flag.BoolVar(&autoScalingRunnerSetOnly, "auto-scaling-runner-set-only", false, "Make controller only reconcile AutoRunnerScaleSet object.")
149152
flag.StringVar(&updateStrategy, "update-strategy", "immediate", `Resources reconciliation strategy on upgrade with running/pending jobs. Valid values are: "immediate", "eventual". Defaults to "immediate".`)
150153
flag.Var(&autoScalerImagePullSecrets, "auto-scaler-image-pull-secrets", "The default image-pull secret name for auto-scaler listener container.")
154+
flag.IntVar(&k8sClientRateLimiterQPS, "k8s-client-rate-limiter-qps", 20, "The QPS value of the K8s client rate limiter.")
155+
flag.IntVar(&k8sClientRateLimiterBurst, "k8s-client-rate-limiter-burst", 30, "The burst value of the K8s client rate limiter.")
151156
flag.Parse()
152157

153158
runnerPodDefaults.RunnerImagePullSecrets = runnerImagePullSecrets
@@ -219,7 +224,11 @@ func main() {
219224
})
220225
}
221226

222-
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
227+
cfg := ctrl.GetConfigOrDie()
228+
cfg.QPS = float32(k8sClientRateLimiterQPS)
229+
cfg.Burst = k8sClientRateLimiterBurst
230+
231+
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
223232
Scheme: scheme,
224233
Metrics: metricsserver.Options{
225234
BindAddress: metricsAddr,

0 commit comments

Comments
 (0)