Make k8s client rate limiter parameters configurable (#3848)

Co-authored-by: Taketoshi Fujiwara <t-b-fujiwara@mercari.com>
This commit is contained in:
Bassem Dghaidi 2024-12-13 15:37:01 +01:00 committed by GitHub
parent 488b0956fd
commit 7e04027d19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 1 deletions

View File

@ -85,6 +85,12 @@ spec:
{{- range .Values.flags.excludeLabelPropagationPrefixes }} {{- range .Values.flags.excludeLabelPropagationPrefixes }}
- "--exclude-label-propagation-prefix={{ . }}" - "--exclude-label-propagation-prefix={{ . }}"
{{- end }} {{- end }}
{{- with .Values.flags.k8sClientRateLimiterQPS }}
- "--k8s-client-rate-limiter-qps={{ . }}"
{{- end }}
{{- with .Values.flags.k8sClientRateLimiterBurst }}
- "--k8s-client-rate-limiter-burst={{ . }}"
{{- end }}
command: command:
- "/manager" - "/manager"
{{- with .Values.metrics }} {{- with .Values.metrics }}

View File

@ -135,3 +135,7 @@ flags:
## Labels that match prefix specified in the list are excluded from propagation. ## Labels that match prefix specified in the list are excluded from propagation.
# excludeLabelPropagationPrefixes: # excludeLabelPropagationPrefixes:
# - "argocd.argoproj.io/instance" # - "argocd.argoproj.io/instance"
## Defines the K8s client rate limiter parameters.
# k8sClientRateLimiterQPS: 20
# k8sClientRateLimiterBurst: 30

11
main.go
View File

@ -105,6 +105,9 @@ func main() {
opts = actionsgithubcom.OptionsWithDefault() opts = actionsgithubcom.OptionsWithDefault()
commonRunnerLabels commaSeparatedStringSlice commonRunnerLabels commaSeparatedStringSlice
k8sClientRateLimiterQPS int
k8sClientRateLimiterBurst int
) )
var c github.Config var c github.Config
err = envconfig.Process("github", &c) 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.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.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.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() flag.Parse()
runnerPodDefaults.RunnerImagePullSecrets = runnerImagePullSecrets 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, Scheme: scheme,
Metrics: metricsserver.Options{ Metrics: metricsserver.Options{
BindAddress: metricsAddr, BindAddress: metricsAddr,