Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Updating Locust to v0.9.0 and using official Dockerfile #7970

Closed
wants to merge 13 commits into from
4 changes: 2 additions & 2 deletions stable/locust/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: locust
description: A modern load testing framework
version: 0.3.0
appVersion: 0.7.5
version: 0.4.0
appVersion: 0.9.0
maintainers:
- name: so0k
email: vincent.drl@gmail.com
Expand Down
12 changes: 8 additions & 4 deletions stable/locust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testing using Kubernetes.

## Pre Requisites:

* Requires (and tested with) helm `v2.1.2` or above.
* Requires (and tested with) helm `v2.10.0` or above.

## Chart details

Expand All @@ -21,20 +21,24 @@ This chart will do the following:
To install the chart with the release name `locust-nymph` in the default namespace:

```bash
helm install -n locust-nymph --set master.config.target-host=http://site.example.com stable/locust
helm install -n locust-nymph --set master.config.target-url=http://site.example.com stable/locust
```

| Parameter | Description | Default |
| ---------------------------- | ---------------------------------- | ----------------------------------------------------- |
| `Name` | Locust master name | `locust` |
| `image.repository` | Locust container image name | `quay.io/honestbee/locust` |
| 'createTestScripts' | Use Helm to create the test scripts | 'true' |
| `image.repository` | Locust container image name | `garland/locust ` |
| `image.tag` | Locust Container image tag | `0.7.5` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the image tag here as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. This will change once Locust.io setups their own docker hub repo. I can update it then. I am following up with them on this here: locustio/locust#850 (comment)

| `image.pullSecrets` | Locust Container image registry secret | `None` |
| 'ingress.enable' | Enable ingress to expose the master | 'false' |
| `master.config.target-url` | locust target host | `http://site.example.com` |
| 'master.nodeSelectors.enable'| Enable nodeSelector usage | 'false' |
| 'master.tolerations.enable' | Enable tolerations/taint usage | 'false' |
| `service.type` | k8s service type exposing master | `NodePort` |
| `service.nodePort` | Port on cluster to expose master | `0` |
| `service.annotations` | KV containing custom annotations | `{}` |
| `service.extraLabels` | KV containing extra labels | `{}` |
| `master.config.target-host` | locust target host | `http://site.example.com` |
| `worker.config.locust-script`| locust script to run | `/locust-tasks/tasks.py` |
| `worker.replicaCount` | Number of workers to run | `2` |

Expand Down
2 changes: 1 addition & 1 deletion stable/locust/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def status(self):
class ElbWarmer(HttpLocust):
task_set = ElbTasks
min_wait = 1000
max_wait = 3000
max_wait = 3000
4 changes: 4 additions & 0 deletions stable/locust/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name "worker" | trunc 63 -}}
{{- end -}}

{{- define "locust.ingress" -}}
{{- printf "%s-%s" .Release.Name "ingress" | trunc 63 -}}
{{- end -}}

{{/*
Create fully qualified configmap name.
*/}}
Expand Down
37 changes: 37 additions & 0 deletions stable/locust/templates/ingres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ if .Values.ingress.enable }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "locust.ingress" . }}
namespace: {{ .Values.namespace }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: {{ template "locust.fullname" . }}
component: "ingress"
annotations:
kubernetes.io/ingress.class: "{{ .Values.ingress.ingressClass }}"
# Setup Let's Encrypt Certificates
{{ if .Values.ingress.enableTLS }}
kubernetes.io/tls-acme: "{{ .Values.ingress.enableTlsAcme }}"
{{ end }}
{{ if .Values.ingress.annotations.enable }}
nginx.ingress.kubernetes.io/whitelist-source-range: "{{ .Values.ingress.annotations.whitelistSourceRange }}"
{{ end }}
spec:
{{ if .Values.ingress.enableTLS }}
tls:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happen if i dont want tls?
need to make it configurable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated to make this configurable.

- hosts:
- "{{ .Values.ingress.hostname }}"
secretName: {{ template "locust.ingress" . }}-locust-tls
{{ end }}
rules:
- host: "{{ .Values.ingress.hostname }}"
http:
paths:
- path: /
backend:
serviceName: {{ template "locust.master-svc" . }}
servicePort: {{ .Values.service.internalPort }}
{{ end }}
21 changes: 17 additions & 4 deletions stable/locust/templates/master-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "locust.master" . }}
Expand All @@ -10,6 +10,10 @@ metadata:
component: master
spec:
replicas: 1
selector:
matchLabels:
component: master
app: {{ template "locust.fullname" . }}
strategy:
type: RollingUpdate
rollingUpdate:
Expand All @@ -30,17 +34,18 @@ spec:
- name: locust
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["-f", "$(LOCUSTFILE_PATH)", "-H", "$(TARGET_URL)", "--master", "--loglevel=$(LOGLEVEL)"]
resources:
{{ toYaml .Values.worker.resources | indent 10 }}
env:
{{- range $key, $value := .Values.master.config }}
- name: {{ $key | upper | replace "-" "_" }}
value: {{ $value | quote }}
{{- end }}
- name: LOCUST_MODE
value: "master"
- name: LOCUST_SCRIPT
- name: LOCUSTFILE_PATH
value: {{ index .Values.worker.config "locust-script" | quote }}
- name: LOGLEVEL
value: {{ .Values.master.logLevel }}
ports:
- containerPort: {{ .Values.service.internalPort }}
name: loc-master-web
Expand All @@ -64,6 +69,14 @@ spec:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
{{ if .Values.master.nodeSelectors.enable }}
nodeSelector:
{{ toYaml .Values.master.nodeSelectors.items | indent 8 }}
{{- end }}
{{ if .Values.master.tolerations.enable }}
tolerations:
{{ toYaml .Values.master.tolerations.items | indent 6 }}
{{- end }}
volumes:
- name: "locust-tasks"
configMap:
Expand Down
3 changes: 3 additions & 0 deletions stable/locust/templates/worker-cm.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ if .Values.createTestScripts }}
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -9,3 +11,4 @@ metadata:
app: {{ template "locust.fullname" . }}
data:
{{ (.Files.Glob "tasks/*").AsConfig | indent 2 }}
{{ end }}
27 changes: 19 additions & 8 deletions stable/locust/templates/worker-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "locust.worker" . }}
Expand All @@ -10,6 +10,10 @@ metadata:
component: worker
spec:
replicas: {{ default 2 .Values.worker.replicaCount }}
selector:
matchLabels:
component: worker
app: {{ template "locust.fullname" . }}
strategy:
type: RollingUpdate
rollingUpdate:
Expand All @@ -29,6 +33,7 @@ spec:
- name: locust
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["-f", "$(LOCUST_SCRIPT)", "-H", "$(TARGET_URL)", "--slave", "--master-host=$(LOCUST_MASTER_HOST)", "--master-port=5557", "--loglevel=$(LOGLEVEL)"]
volumeMounts:
- name: locust-tasks
mountPath: /locust-tasks/
Expand All @@ -37,16 +42,22 @@ spec:
- name: {{ $key | upper | replace "-" "_" }}
value: {{ $value | quote }}
{{- end }}
- name: LOCUST_MODE
value: "worker"
- name: LOCUST_MASTER
- name: LOCUST_MASTER_HOST
value: {{ template "locust.master-svc" . }}
- name: LOCUST_MASTER_WEB
value: "{{ .Values.service.internalPort }}"
- name: TARGET_HOST
value: {{ index .Values.master.config "target-host" | quote }}
- name: TARGET_URL
value: {{ index .Values.master.config "target-url" | quote }}
- name: LOGLEVEL
value: {{ .Values.worker.logLevel }}
resources:
{{ toYaml .Values.worker.resources | indent 10 }}
{{ if .Values.worker.nodeSelectors.enable }}
nodeSelector:
{{ toYaml .Values.worker.nodeSelectors.items | indent 8 }}
{{- end }}
{{ if .Values.worker.tolerations.enable }}
tolerations:
{{ toYaml .Values.worker.tolerations.items | indent 6 }}
{{- end }}
restartPolicy: Always
volumes:
- name: "locust-tasks"
Expand Down
43 changes: 40 additions & 3 deletions stable/locust/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Name: locust

image:
repository: quay.io/honestbee/locust
tag: 0.7.5
repository: garland/locust
tag: 0.9.0
pullPolicy: IfNotPresent
pullSecrets: []

Expand All @@ -16,19 +16,32 @@ service:
extraLabels: {}
master:
config:
target-host: https://site.example.com
target-url: https://site.example.com
logLevel: INFO
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
nodeSelectors:
enable: false
items:
k8s.info/application: locust
tolerations:
enable: false
items:
- key: "application"
operator: "Equal"
value: "locust"
effect: "NoSchedule"
worker:
config:

# all files from tasks folder are mounted under `/locust-tasks`
locust-script: "/locust-tasks/tasks.py"
logLevel: INFO
replicaCount: 2
resources:
limits:
Expand All @@ -37,3 +50,27 @@ worker:
requests:
cpu: 100m
memory: 128Mi
nodeSelectors:
enable: false
items:
k8s.info/application: locust
tolerations:
enable: false
items:
- key: "application"
operator: "Equal"
value: "locust"
effect: "NoSchedule"

# Flag to create the test script from this chart or not.
createTestScripts: true

ingress:
enable: false
enableTLS: false
ingressClass: nginx
enableTlsAcme: false
hostname: locust.example.com
annotations:
enable: false
whitelistSourceRange: "1.1.1.1/32,2.2.2.2/32"