From 11d3c60ac1b8a3dcc7d43b07adcb7219df91daa5 Mon Sep 17 00:00:00 2001 From: Kirmayer Elad <6572119+ekirmayer@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:58:02 +0200 Subject: [PATCH] [stable/locust] Support Keda scaled object (#640) Support Keda scaled object --- stable/locust/Chart.yaml | 2 +- stable/locust/README.md | 8 +++++-- stable/locust/templates/worker-keda.yaml | 27 ++++++++++++++++++++++++ stable/locust/values.yaml | 14 ++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 stable/locust/templates/worker-keda.yaml diff --git a/stable/locust/Chart.yaml b/stable/locust/Chart.yaml index 2e7c3e97..8775dc64 100644 --- a/stable/locust/Chart.yaml +++ b/stable/locust/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: locust -version: "0.32.2" +version: "0.32.3" appVersion: 2.32.2 home: https://github.com/locustio/locust icon: https://locust.io/static/img/logo.png diff --git a/stable/locust/README.md b/stable/locust/README.md index cde7f8ec..837c2e9b 100644 --- a/stable/locust/README.md +++ b/stable/locust/README.md @@ -1,6 +1,6 @@ # locust -![Version: 0.32.2](https://img.shields.io/badge/Version-0.32.2-informational?style=flat-square) ![AppVersion: 2.32.2](https://img.shields.io/badge/AppVersion-2.32.2-informational?style=flat-square) +![Version: 0.32.3](https://img.shields.io/badge/Version-0.32.3-informational?style=flat-square) ![AppVersion: 2.32.2](https://img.shields.io/badge/AppVersion-2.32.2-informational?style=flat-square) A chart to install Locust, a scalable load testing tool written in Python. @@ -37,7 +37,7 @@ helm install --generate-name oci://ghcr.io/deliveryhero/helm-charts/locust To install a specific version of this chart: ```console -helm install --generate-name oci://ghcr.io/deliveryhero/helm-charts/locust --version 0.32.2 +helm install --generate-name oci://ghcr.io/deliveryhero/helm-charts/locust --version 0.32.3 ``` To install the chart with the release name `my-release`: @@ -148,6 +148,10 @@ helm install my-release oci://ghcr.io/deliveryhero/helm-charts/locust -f values. | worker.hpa.minReplicas | int | `1` | | | worker.hpa.targetCPUUtilizationPercentage | int | `40` | | | worker.image | string | `""` | A custom docker image including tag | +| worker.keda.cooldownPeriod | int | `30` | | +| worker.keda.enabled | bool | `false` | | +| worker.keda.pollingInterval | int | `15` | | +| worker.keda.triggers | string | `"# https://keda.sh/docs/latest/scalers/metrics-api/\n- type: metrics-api\n metadata:\n activationTargetValue: \"0\"\n targetValue: \"50\" # Scale pods based on target users\n url: \"http://{{ template \"locust.fullname\" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ $.Values.service.port }}/stats/requests\"\n format: json\n valueLocation: 'user_count'\n"` | | | worker.logLevel | string | `"INFO"` | Log level. Can be INFO or DEBUG | | worker.nodeSelector | object | `{}` | Overwrites nodeSelector from global | | worker.pdb.enabled | bool | `false` | Whether to create a PodDisruptionBudget for the worker pods | diff --git a/stable/locust/templates/worker-keda.yaml b/stable/locust/templates/worker-keda.yaml new file mode 100644 index 00000000..d4d3566f --- /dev/null +++ b/stable/locust/templates/worker-keda.yaml @@ -0,0 +1,27 @@ +{{- if .Values.worker.keda.enabled }} +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: {{ template "locust.fullname" . }} + labels: +{{ include "locust.labels" . | indent 4 }} + component: "worker" +{{- with .Values.worker.keda.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + scaleTargetRef: + kind: Deployment + apiVersion: apps/v1 + name: {{ template "locust.fullname" . }}-worker + pollingInterval: {{ .Values.worker.keda.pollingInterval }} + cooldownPeriod: {{ .Values.worker.keda.cooldownPeriod }} + minReplicaCount: {{ .Values.worker.hpa.minReplicas }} + maxReplicaCount: {{ .Values.worker.hpa.maxReplicas }} + fallback: + failureThreshold: {{ .Values.worker.keda.failureThreshold | default 3 }} + replicas: {{ .Values.worker.keda.fallbackReplicas | default .Values.worker.hpa.minReplicas }} + triggers: + {{- tpl .Values.worker.keda.triggers . | nindent 4}} +{{- end }} diff --git a/stable/locust/values.yaml b/stable/locust/values.yaml index c6d77224..2391450d 100644 --- a/stable/locust/values.yaml +++ b/stable/locust/values.yaml @@ -154,6 +154,20 @@ worker: minReplicas: 1 maxReplicas: 100 targetCPUUtilizationPercentage: 40 + keda: + enabled: false + pollingInterval: 15 + cooldownPeriod: 30 + # worker.keda,triggers - Allow passing required triggers to scale upon as string template for complex triggering + triggers: | + # https://keda.sh/docs/latest/scalers/metrics-api/ + - type: metrics-api + metadata: + activationTargetValue: "0" + targetValue: "50" # Scale pods based on target users + url: "http://{{ template "locust.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ $.Values.service.port }}/stats/requests" + format: json + valueLocation: 'user_count' # worker.resources -- resources for the locust worker resources: {} # limits: