Back to Charts

⚠️ Repo Archive Notice

stable/locust/README.md

latest5.6 KB
Original Source

⚠️ Repo Archive Notice

As of Nov 13, 2020, charts in this repo will no longer be updated. For more information, see the Helm Charts Deprecation and Archive Notice, and Update.

Locust Helm Chart

This is a templated deployment of Locust for Distributed Load testing using Kubernetes.

DEPRECATION NOTICE

This chart is deprecated and no longer supported.

Pre Requisites:

  • Requires (and tested with) helm v2.1.2 or above.

Chart details

This chart will do the following:

  • Convert all files in tasks/ folder into a configmap
  • If an existing configmap is specified, it will be used instead of building one from the chart
  • Create a Locust master and Locust worker deployment with the Target host and Tasks file specified.

Installing the chart

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
ParameterDescriptionDefault
NameLocust master namelocust
image.repositoryLocust container image namegreenbirdit/locust
image.tagLocust Container image tag0.9.0
image.pullSecretsLocust Container image registry secretNone
service.typek8s service type exposing masterNodePort
service.nodePortPort on cluster to expose master0
service.annotationsKV containing custom annotations{}
service.extraLabelsKV containing extra labels{}
extraVolumesList of extra Volumes[]
extraVolumeMountsList of extra Volume Mounts[]
extraEnvsList of extra Environment Variables[]
master.config.target-hostlocust target hosthttp://site.example.com
master.nodeSelectork8s nodeselector{}
master.tolerationsk8s tolerations[]
worker.config.locust-scriptlocust script to run/locust-tasks/tasks.py
worker.config.configmapNameconfigmap to mount locust scripts fromempty, configmap is created from tasks folder in Chart
worker.replicaCountNumber of workers to run2
worker.nodeSelectork8s nodeselector{}
worker.tolerationsk8s tolerations[]
worker.affinitiesk8s affinities{}

Specify parameters using --set key=value[,key=value] argument to helm install

Alternatively a YAML file that specifies the values for the parameters can be provided like this:

bash
$ helm install --name my-release -f values.yaml stable/locust

Creating configmap with your Locust task files

You're probably developing your own Locust scripts that you want to run in this distributed setup. To get those scripts into this deployment you can fork the chart and put them into the tasks folder. From there they will be converted to a configmap and mounted for use in Locust.

Another solution, if you don't want to fork the Chart, is to put your Locust scripts in a configmap and provide the name as a config parameter in values.yaml. You can read more on the use of configmaps as volumes in pods here.

If you have your Locust task files in a folder named "scripts" you would use something like the following command:

kubectl create configmap locust-worker-configs --from-file path/to/scripts

Interacting with Locust

Get the Locust URL following the Post Installation notes. Using port forwarding you should be able to connect to the web ui on Locust master node.

You can start the swarm from the command line using port forwarding as follows:

for example:

bash
export LOCUST_URL=http://127.0.0.1:8089

Start / Monitor & Stop the Locust swarm via the web panel or with following commands:

Start:

bash
curl -XPOST $LOCUST_URL/swarm -d"locust_count=100&hatch_rate=10"

Monitor:

bash
watch -n 1 "curl -s $LOCUST_URL/stats/requests | jq -r '[.user_count, .total_rps, .state] | @tsv'"

Stop:

bash
curl $LOCUST_URL/stop