Skip to content

Distributed load testing using locust, kubernetes and helm

License

Notifications You must be signed in to change notification settings

maximenoel8/locust-kubernetes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build-status

Distributed load testing using kubernetes and locust

The repository contains everything needed to run a distributed load testing environment in kubernetes using a locust master and locust slaves.

Table of contents

  1. Project structure
  2. Prerequisites
  3. Running
    1. tl;dr
    2. Detailed installation
      1. Preparing the local kubernetes cluster
      2. Building the docker image
      3. Installing the helm charts
      4. Confirm the installation and access locust dashboard
  4. Architecture

Project structure

.
├── .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
└── ...

Prerequisites

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

Running

Deploy locus project

helm install directory-locust-kubernetes/loadtest-chart/ --namespace locust --name locust --set hostAliases.ip=${web_ip}

Start swarm by command lines

Locally :

curl -X POST -F 'locust_count=500' -F 'hatch_rate=5' http://<locust-url>:<locust-port>/swarm

In kubernetes :

kubectl run --generator=run-pod/v1 startlocust --image=djbingham/curl --restart='OnFailure' -i --tty --rm --command -- curl -X POST -F 'locust_count=500' -F 'hatch_rate=10' http://locust-master.locust.svc.cluster.local:8089/swarm

Stop load test by command lines

Locally:

curl http://<locust-url>:<locust-port>/stop

In kubernetes :

kubectl run --generator=run-pod/v1 stoplocuts --generator=run-pod/v1 --image=djbingham/curl --restart='OnFailure' -i --tty --rm --command -- curl http://locust-master.locust.svc.cluster.local:8089/stop

Detailed installation

Building the docker image

In the root of the repo, run docker build docker-image -t locust-tasks:latest

locust

Architecture

About

Distributed load testing using locust, kubernetes and helm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Smarty 39.2%
  • Shell 24.4%
  • Dockerfile 21.6%
  • Python 14.8%