The repository contains everything needed to run a distributed load testing environment in kubernetes using a locust master and locust slaves.
.
├── .vscode # launch.json and tasks.json needed to debug the tasks.py in vsc
├── docker-image # The shared docker image for locust masters and slaves
│ ├── locust-tasks # Python source code
| | ├── requirements.txt # Python dependencies for tasks.py
| | ├── tasks.py # Locust tasks
| ├── run.sh # Shell script to determine if the docker containers should be master or slave
│ ├── Dockerfile # Dockerfile
├── loadtest-chart # Helm chart
| ├── templates # Helm templates
| | ├── _helpers.tpl # Helm helpers
| | ├── locust-master-deployment.yaml # Kubernetes deployment configuration for locust master
| | ├── locust-master-service.yaml # Kubernetes service configuration for locust master
| | ├── locust-slave-deployment.yaml # Kubernetes deployment configuration for locust slaves
| ├── Chart.yaml # Chart definition
| ├── values.yaml # Chart definition
└── ...
Product | Version | Link |
---|---|---|
Python | 2.7.15 | Windows, MacOS |
Docker | 18.03.0-ce (23751) | Windows, MacOS |
kubectl | 2.0.0 | Windows, MacOS |
Minikube | 0.27.0 | Windows, MacOS |
helm | 2.9.1 | Windows MacOS |
Start minikube
minikube start
Set docker environment to minikube
eval $(minikube docker-env)
Build docker image
docker build docker-image -t locust-tasks:latest
Install helm charts onto kubernetes cluster
helm install loadtest-chart --name locust
List services to find locust URL
minikube service list
Start a local kubernetes cluster with minikube by running the following command minikube start
Confirm that everything is OK by running minikube status
it should return something like:
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
Now that we have minikube running we are going to want to point our docker environment to the one running on the cluster. Do this with the command eval $(minikube docker-env)
. You can unset the environment at any time by running eval $(docker-machine env --unset)
.
Confirm that the docker environment is correct by running docker images
. You should see a list of related kubernetes images like k8s.gcr.io.
In the root of the repo, run docker build docker-image -t locust-tasks:latest
Now that we have the docker image built and registered in the minikube docker registry. We can get our deployments and services for locust into our kubernetes cluster. Simply run helm install loadtest-chart --name locust
.
To confirm that locust is running in our cluster. Run minikube service list
. You should find locust-loadtest-chart-master with 3 URL's. Go to the first one and you should now see the locust load testing frontpage.