A simple load testing framework for Kubernetes workloads using locust.
Kubernetes enables rapid deployment of server-based applications on top of elastic infrastructure that can scale with your needs. An important part of a rapid continuous deployment strategy includes proof that your application can scale and remain stable under load. This project includes a re-usable locust container image Dockerfile and a re-usable deployment configuration using Helm that will get you load-testing on your Kubernetes clusters in no time.
locust
is a python based load testing tool that runs in a master/worker configuration. To setup
your loadtest, you use a simple python library to define tests and then launch the master and
workers with the file containing the main entry point for your test.
Please see the Locust Home Page for more information on creating and running your load tests.
This framework simplifies the use of locust
in kubernetes by offering a helm
deployment
that will get a load test out of your git
repository before running it on the generic
locust container defined in this project's Dockerfile
.
If you're starting from scratch and don't have a Kubernetes cluster, or just want to test it locally,
install minikube
. Minikube runs on a VM on your laptop and is easy to install.
You will find more information on installing minikube
here
Next you'll need two other tools:
kubectl
- is the CLI tool for kubernetes and can be found herehelm
- is the deployment tool for kubernetes. More information and download links can be found here
Once you've got your cluster started and have installed helm
and kubectl
, you can become familiar with this framework
by using the supplied sample-app
found in the contrib/sample-app
folder.
Step 1: Setup your git ssh key, so kubernetes call pull your loadtest
kubectl create secret generic git-creds --from-file=ssh=~/.ssh/id_rsa
Step 2 Startup the sample server with helm
helm install contrib/sample-app/charts/sample-app --name sample-app
Step 3 Startup the load test with helm
helm install charts/locust-loadtest -f contrib/sample-app/locust-values.yaml --name locust
Step 4 Verify that its all running and get the URI for locust
Open up your kubernetes dashboad (on minikube you type: minikube dashboard
), select the default
namespace and check that
you have:
- 2 sample-app pods
- 1 locust master pod
- 2 locust worker pods
Next click on Services
and then find the NodePort where locust's control panel is exposed. This will be a port that is > 30000
Step 5 Start Testing:
- Load the Locust Page. If you're using minikube, it will use the same IP as your dashboard followed by the NodePort of the locust service.
- Setup the number of users to simulate: 100
- Setup the Hatch Rate: 2
Now you should see the test page reporting 2 Slaves along with updating metrics for your test.
TODO: Describe the deployment in more detail
TODO: Describe extending the sample and writing a load test form scratch