Skip to content

Commit

Permalink
fix rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisBRENON committed Jan 6, 2025
1 parent e29b9e8 commit d228d9c
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 50 deletions.
28 changes: 27 additions & 1 deletion stable/locust/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ description: |
This chart will setup everything required to run a full distributed locust environment with any amount of workers.
This chart will also create configmaps for storing the locust files in Kubernetes, this way there is no need to build custom docker images.
Locust requires locust files to execute load testing, and this chart provides different ways to populate locust files.
## Kubernetes ConfigMap
This chart can create configmaps for storing the locust files in Kubernetes, this way there is no need to build custom docker images.
By default it will install using an example locustfile and lib from [stable/locust/locustfiles/example](https://github.com/deliveryhero/helm-charts/tree/master/stable/locust/locustfiles/example). When you want to provide your own locustfile, you will need to create 2 configmaps using the structure from that example:
Expand All @@ -29,3 +33,25 @@ description: |
--set loadtest.locust_locustfile_configmap=my-loadtest-locustfile \
--set loadtest.locust_lib_configmap=my-loadtest-lib
```
## Git Sync
Another way to fetch locust files in the pods is to continously track a git repository containing the files.
While activating this feature, you also have to disable the default ConfigMap-based provisioning, through a custom `values.yaml` file:
```yaml
loadtest:
enabled = false
locustfiles:
gitSync:
enabled = true
```
Then configure the gitSync process to fetch the right repository and the right files:
```yaml
locustfiles:
gitSync:
repo: https://github.com/username/reponame.git
```
60 changes: 43 additions & 17 deletions stable/locust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ A chart to install Locust, a scalable load testing tool written in Python.

This chart will setup everything required to run a full distributed locust environment with any amount of workers.

This chart will also create configmaps for storing the locust files in Kubernetes, this way there is no need to build custom docker images.
Locust requires locust files to execute load testing, and this chart provides different ways to populate locust files.

## Kubernetes ConfigMap

This chart can create configmaps for storing the locust files in Kubernetes, this way there is no need to build custom docker images.

By default it will install using an example locustfile and lib from [stable/locust/locustfiles/example](https://github.com/deliveryhero/helm-charts/tree/master/stable/locust/locustfiles/example). When you want to provide your own locustfile, you will need to create 2 configmaps using the structure from that example:

Expand All @@ -24,6 +28,28 @@ helm install locust oci://ghcr.io/deliveryhero/helm-charts/locust \
--set loadtest.locust_lib_configmap=my-loadtest-lib
```

## Git Sync

Another way to fetch locust files in the pods is to continously track a git repository containing the files.

While activating this feature, you also have to disable the default ConfigMap-based provisioning, through a custom `values.yaml` file:

```yaml
loadtest:
enabled = false
locustfiles:
gitSync:
enabled = true
```
Then configure the gitSync process to fetch the right repository and the right files:
```yaml
locustfiles:
gitSync:
repo: https://github.com/username/reponame.git
```
**Homepage:** <https://github.com/locustio/locust>
## How to install this chart
Expand Down Expand Up @@ -72,17 +98,17 @@ helm install my-release oci://ghcr.io/deliveryhero/helm-charts/locust -f values.
| image.repository | string | `"locustio/locust"` | |
| image.tag | string | `"2.32.2"` | |
| imagePullSecrets | list | `[]` | |
| images.defaultLocustRepository | string | `"locustio/locust"` | |
| images.defaultLocustTag | string | `"2.32.2"` | |
| images.defaultLocustRepository | string | `"locustio/locust"` | default image used by locust containers (master and workers) |
| images.defaultLocustTag | string | `"2.32.2"` | default tag used by locust containers (master and workers) |
| images.gitSync.pullPolicy | string | `"IfNotPresent"` | |
| images.gitSync.repository | string | `"registry.k8s.io/git-sync/git-sync"` | |
| images.gitSync.tag | string | `"v4.1.0"` | |
| images.gitSync.repository | string | `"registry.k8s.io/git-sync/git-sync"` | image used by gitSync container |
| images.gitSync.tag | string | `"v4.1.0"` | tag used by gitSync container |
| images.master.pullPolicy | string | `"IfNotPresent"` | |
| images.master.repository | string | `nil` | |
| images.master.tag | string | `nil` | |
| images.master.repository | string | `nil` | image used by locust master container |
| images.master.tag | string | `nil` | tag used by locust master container |
| images.worker.pullPolicy | string | `"IfNotPresent"` | |
| images.worker.repository | string | `nil` | |
| images.worker.tag | string | `nil` | |
| images.worker.repository | string | `nil` | image used by locust worker containers |
| images.worker.tag | string | `nil` | tag used by locust worker containers |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
Expand All @@ -109,21 +135,21 @@ helm install my-release oci://ghcr.io/deliveryhero/helm-charts/locust -f values.
| locustfiles.gitSync.containerLifecycleHooks | object | `{}` | |
| locustfiles.gitSync.containerName | string | `"git-sync"` | |
| locustfiles.gitSync.depth | int | `1` | |
| locustfiles.gitSync.enabled | bool | `false` | |
| locustfiles.gitSync.enabled | bool | `false` | Enable the Git Sync feature (mutually exclusive with loadtest.enabled) |
| locustfiles.gitSync.env | list | `[]` | |
| locustfiles.gitSync.envFrom | string | `nil` | |
| locustfiles.gitSync.envFrom | string | `nil` | add variables from secret into gitSync containers, such proxy-config |
| locustfiles.gitSync.extraVolumeMounts | list | `[]` | |
| locustfiles.gitSync.maxFailures | int | `0` | |
| locustfiles.gitSync.maxFailures | int | `0` | the number of consecutive failures allowed before aborting |
| locustfiles.gitSync.period | string | `"5s"` | |
| locustfiles.gitSync.ref | string | `"main"` | |
| locustfiles.gitSync.repo | string | `nil` | |
| locustfiles.gitSync.ref | string | `"main"` | Git reference to pull |
| locustfiles.gitSync.repo | string | `nil` | Git repository to synchronize |
| locustfiles.gitSync.resources | object | `{}` | |
| locustfiles.gitSync.securityContext | object | `{}` | |
| locustfiles.gitSync.securityContexts.container | object | `{}` | |
| locustfiles.gitSync.subPath | string | `"locustfiles"` | |
| locustfiles.gitSync.subPath | string | `"locustfiles"` | subpath within the repo where locustfiles are located, should be "" if files are at repo root |
| locustfiles.gitSync.uid | int | `65533` | |
| locustfiles.mountPath | string | `"/mnt/locust"` | |
| locustfiles.requirements | string | `nil` | |
| locustfiles.mountPath | string | `"/mnt/locust"` | the path of the locustfiles (without trailing backslash) |
| locustfiles.requirements | string | `nil` | Path to a file containing requirements to install |
| master.affinity | object | `{}` | Overwrites affinity from global |
| master.args | list | `[]` | Any extra command args for the master |
| master.auth.enabled | bool | `false` | When enabled using image tag 2.21.0 or later you do not need username or pass word. Older image tags you are required to |
Expand Down
23 changes: 20 additions & 3 deletions stable/locust/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,38 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- template "locust.legacy_image" -}}
{{- else }}
{{- $repository := .Values.images.master.repository | default .Values.images.defaultLocustRepository -}}
{{- $tag := .Values.images.master.tag | default .Values.defaultLocustTag -}}
{{- $tag := .Values.images.master.tag | default .Values.images.defaultLocustTag -}}
{{- printf "%s:%s" $repository $tag -}}
{{- end }}
{{- end }}

{{- define "locust.master_pull_policy" -}}
{{- if .Values.image }}
{{- .Values.image.pullPolicy -}}
{{- else }}
{{- .Values.images.master.pullPolicy -}}
{{- end }}
{{- end }}

{{- define "locust.worker_image" -}}
{{- if .Values.image }}
{{- template "locust.legacy_image" -}}
{{- else }}
{{- $repository := .Values.images.worker.repository | default .Values.images.defaultLocustRepository -}}
{{- $tag := .Values.images.worker.tag | default .Values.defaultLocustTag -}}
{{- $tag := .Values.images.worker.tag | default .Values.images.defaultLocustTag -}}
{{- printf "%s:%s" $repository $tag -}}
{{- end }}
{{- end }}

{{- define "locust.worker_pull_policy" -}}
{{- if .Values.image }}
{{- .Values.image.pullPolicy -}}
{{- else }}
{{- .Values.images.worker.pullPolicy -}}
{{- end }}
{{- end }}


{{- define "git_sync_image" -}}
{{- printf "%s:%s" .Values.images.gitSync.repository .Values.images.gitSync.tag }}
{{- end }}
Expand Down Expand Up @@ -182,7 +199,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- end }}

{{- define "locust.locustfiles_mount" -}}
{{- define "locust.locustfiles_mount" }}
- name: locustfiles
mountPath: {{ .Values.locustfiles.mountPath }}
readOnly: {{ .Values.locustfiles.gitSync.enabled | ternary "True" "False" }}
Expand Down
34 changes: 21 additions & 13 deletions stable/locust/templates/master-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ spec:
{{- end }}
initContainers:
{{- if .Values.locustfiles.gitSync.enabled }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 8 }}
{{- include "git_sync_container" (dict "Values" .Values "is_init" "true" "Template" .Template) | nindent 6 }}
{{- end }}
containers:
{{- if .Values.locustfiles.gitSync.enabled }}
{{- include "git_sync_container" . | nindent 8 }}
{{- include "git_sync_container" . | nindent 6 }}
{{- end }}
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ template "locust.master_image" }}
image: {{ template "locust.master_image" . }}
{{- with .Values.master.command }}
command:
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -83,20 +83,22 @@ spec:
{{- if .Values.loadtest.excludeTags }}
- --exclude-tags {{ .Values.loadtest.excludeTags }}
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
imagePullPolicy: {{ template "locust.master_pull_policy" . }}
resources:
{{ toYaml .Values.master.resources | indent 10 }}
volumeMounts:
{{- if .Values.loadtest.locust_locustfile_configmap}}
{{- if .Values.loadtest.enabled }}
{{- if .Values.loadtest.locust_locustfile_configmap}}
- name: locustfile
mountPath: "{{ .Values.loadtest.locust_locustfile_path }}"
{{- end }}
{{- if .Values.loadtest.locust_lib_configmap }}
{{- end }}
{{- if .Values.loadtest.locust_lib_configmap }}
- name: lib
mountPath: "{{ .Values.loadtest.locust_locustfile_path }}/lib"
{{- end }}
{{- end }}
{{- if .Values.locustfiles.gitSync.enabled }}
{{- include "locust.locustfiles_mount" . | nindent 12 }}
{{- include "locust.locustfiles_mount" . | nindent 10 }}
{{- end }}
- name: config
mountPath: /config
Expand All @@ -117,7 +119,11 @@ spec:
- name: LOCUST_LOGLEVEL
value: "{{ .Values.master.logLevel }}"
- name: LOCUST_LOCUSTFILE
{{- if .Values.loadtest.enabled }}
value: "{{ .Values.loadtest.locust_locustfile_path }}/{{ .Values.loadtest.locust_locustfile }}"
{{- else if .Values.locustfiles.gitSync.enabled }}
value: "{{ .Values.locustfiles.mountPath }}/repo/{{ .Values.locustfiles.gitSync.subPath }}/"
{{- end }}
{{- end }}
{{- range $key, $value := .Values.loadtest.environment }}
- name: {{ $key }}
Expand Down Expand Up @@ -171,19 +177,21 @@ spec:
{{- end }}
restartPolicy: {{ .Values.master.restartPolicy }}
volumes:
{{- if .Values.loadtest.locust_lib_configmap }}
{{- if .Values.loadtest.enabled }}
{{- if .Values.loadtest.locust_lib_configmap }}
- name: lib
configMap:
name: {{ .Values.loadtest.locust_lib_configmap }}
{{- end }}
{{- if .Values.loadtest.locust_locustfile_configmap }}
{{- end }}
{{- if .Values.loadtest.locust_locustfile_configmap }}
- name: locustfile
configMap:
name: {{ .Values.loadtest.locust_locustfile_configmap }}
{{- end }}
{{- end }}
{{- if .Values.dags.gitSync.enabled }}
{{- if .Values.locustfiles.gitSync.enabled }}
- name: locustfiles
emptyDir:
emptyDir: {}
{{- end }}
- name: config
configMap:
Expand Down
32 changes: 20 additions & 12 deletions stable/locust/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ spec:
{{- end }}
containers:
{{- if .Values.locustfiles.gitSync.enabled }}
{{- include "git_sync_container" . | nindent 8 }}
{{- include "git_sync_container" . | nindent 6 }}
{{- end }}
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ template "locust.worker_image" }}
image: {{ template "locust.worker_image" . }}
{{- with .Values.worker.command }}
command:
{{- toYaml . | nindent 8 }}
Expand All @@ -66,20 +66,22 @@ spec:
{{- if .Values.worker.args }}
{{- toYaml .Values.worker.args | nindent 10 }}
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
imagePullPolicy: {{ template "locust.worker_pull_policy" . }}
resources:
{{ toYaml .Values.worker.resources | indent 10 }}
volumeMounts:
{{- if .Values.loadtest.locust_locustfile_configmap}}
{{- if .Values.loadtest.enabled }}
{{- if .Values.loadtest.locust_locustfile_configmap}}
- name: locustfile
mountPath: "{{ .Values.loadtest.locust_locustfile_path }}"
{{- end }}
{{- if .Values.loadtest.locust_lib_configmap }}
{{- end }}
{{- if .Values.loadtest.locust_lib_configmap }}
- name: lib
mountPath: "{{ .Values.loadtest.locust_locustfile_path }}/lib"
{{- end }}
{{- end }}
{{- if .Values.locustfiles.gitSync.enabled }}
{{- include "locust.locustfiles_mount" . | nindent 12 }}
{{- include "locust.locustfiles_mount" . | nindent 10 }}
{{- end }}
- name: config
mountPath: /config
Expand All @@ -104,7 +106,11 @@ spec:
- name: LOCUST_LOGLEVEL
value: "{{ .Values.worker.logLevel }}"
- name: LOCUST_LOCUSTFILE
{{- if .Values.loadtest.enabled }}
value: "{{ .Values.loadtest.locust_locustfile_path }}/{{ .Values.loadtest.locust_locustfile }}"
{{- else if .Values.locustfiles.gitSync.enabled }}
value: "{{ .Values.locustfiles.mountPath }}/repo/{{ .Values.locustfiles.gitSync.subPath }}/"
{{- end }}
{{- end }}
{{- range $key, $value := .Values.worker.environment }}
- name: {{ $key }}
Expand Down Expand Up @@ -133,19 +139,21 @@ spec:
{{- end }}
restartPolicy: {{ .Values.worker.restartPolicy }}
volumes:
{{- if .Values.loadtest.locust_lib_configmap }}
{{- if .Values.loadtest.enabled }}
{{- if .Values.loadtest.locust_lib_configmap }}
- name: lib
configMap:
name: {{ .Values.loadtest.locust_lib_configmap }}
{{- end }}
{{- if .Values.loadtest.locust_locustfile_configmap }}
{{- end }}
{{- if .Values.loadtest.locust_locustfile_configmap }}
- name: locustfile
configMap:
name: {{ .Values.loadtest.locust_locustfile_configmap }}
{{- end }}
{{- end }}
{{- if .Values.dags.gitSync.enabled }}
{{- if .Values.locustfiles.gitSync.enabled }}
- name: locustfiles
emptyDir:
emptyDir: {}
{{- end }}
- name: config
configMap:
Expand Down
Loading

0 comments on commit d228d9c

Please sign in to comment.