{"id":15720078,"url":"https://github.com/mosesliao/kubernetes-locust","last_synced_at":"2025-05-07T15:01:17.682Z","repository":{"id":60793520,"uuid":"312744543","full_name":"mosesliao/kubernetes-locust","owner":"mosesliao","description":"A demo how to use locust on EKS","archived":false,"fork":false,"pushed_at":"2023-04-09T14:56:57.000Z","size":147,"stargazers_count":41,"open_issues_count":0,"forks_count":10,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-31T11:11:38.348Z","etag":null,"topics":["aws-eks","cloud-deployment","kubernetes","load-testing","locust","locust-cluster","locust-docker-image","locust-nodes"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mosesliao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-14T04:24:42.000Z","updated_at":"2025-02-12T22:59:31.000Z","dependencies_parsed_at":"2024-10-24T16:10:45.090Z","dependency_job_id":"f5120962-efa0-45f8-8c2c-dd404bff9d2d","html_url":"https://github.com/mosesliao/kubernetes-locust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosesliao%2Fkubernetes-locust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosesliao%2Fkubernetes-locust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosesliao%2Fkubernetes-locust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosesliao%2Fkubernetes-locust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mosesliao","download_url":"https://codeload.github.com/mosesliao/kubernetes-locust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252902604,"owners_count":21822259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-eks","cloud-deployment","kubernetes","load-testing","locust","locust-cluster","locust-docker-image","locust-nodes"],"created_at":"2024-10-03T21:57:44.039Z","updated_at":"2025-05-07T15:01:16.011Z","avatar_url":"https://github.com/mosesliao.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Introduction\n\nDistributed load testing using cloud computing is an attractive option for a variety of test scenarios.\n\nCloud platforms provide a high degree of infrastructure elasticity, making it easy to test applications and services with large numbers of simulated clients, each generating traffic patterned after users or devices.\n\nAdditionally, the pricing model of cloud computing fits very well with the very elastic nature of load testing.\n\nLocust supports running load tests on multiple machines. It's a perfect fit for Kubernetes which makes distributed deployments, container orchestration and scaling easy.\n\nIn this installment of my Locust experiments, I'll prepare Kubernetes scripts for deploying and managing Locust cluster in AWS EKS and see if there are any surprises along the way.\n\nI will also *NOT* be creating my own locust docker image and instead use the official [locustio/locust](https://hub.docker.com/r/locustio/locust/) image to make sure I use the latest locust version\n\n# Locust distributed mode\n\nRunning Locust in distributed mode is described in its documentation.\nIn short:\n* you can have one master and multiple slave nodes (workers)\n* you need to tell the workers where the master is (give them the IP address and ports)\n* you need to supply each worker with the tests code (locustfiles)\n* the workers need to be able to connect to the master.\n\nThat's pretty much it.\n\n# Kubernetes components\nLet's dive in and go through the building blocks of the Locust cluster to be deployed.\n\nKubernetes' *configmaps* will help configure Locust.\n[One configmap](./scripts-cm.yaml) will hold a proper locustfile and will be mounted as a volume to the master and workers,\n[the second](./locust-cm.yaml) will contain other configuration settings (URL for tested host/service, for example) that will be injected to running Locust nodes as environment variables.\n\n\nI'll use *deployment* in order to \"ask\" K8s for making sure our [master](./master-deployment.yaml) and [slaves](./slave-deployment.yaml) are up and running.\n[The service](./service.yaml) will make the master addressable within the cluster.\n[The nodeport](./nodeport.yml) will help give your nodes an External IP address to your nodes.\n\n# Cluster deployment\n\nTo set up the cluster:\n\n1) Create an EKS cluster via CLI. If you have an existing EKS cluster run `aws eks update-kubeconfig --name \u003cname-of-eks-cluster\u003e`\n\n2) Then run the following:\n\n    \u003e git clone git@github.com:mosesliao/kubernetes-locust.git\n    \n    \u003e cd kubernetes-locust\n    \n    \u003e kubectl create -f nodeport.yaml -f scripts-cm.yaml -f master-deployment.yaml -f service.yaml -f slave-deployment.yaml\n\n*aws eks* command connects to my your eks cluster and crate the components mentioned above.\nIf ran for the first time, it may take a while to complete (if there is no locust docker image on the cluster, it needs to be downloaded first).\nTo see, if locust nodes are running we can inspect if the pods are up:\n\n    \u003e kubectl get -w pods\n    NAME                             READY     STATUS    RESTARTS   AGE\n    locust-master-6dd5cc46d4-xrqt6   1/1     Running   0          26h\n    locust-worker-bc7464db8-bs857    1/1     Running   0          26h\n    locust-worker-bc7464db8-z84kp    1/1     Running   0          26h\n\nFrom the output we can pick up the master name can also take a look at the logs.\n`kubectl logs locust-master-754dc88dd8-zgs7m` should include the following information:\n\n```\n[2020-11-13 01:38:05,978] locust-master-6dd5cc46d4-xrqt6/INFO/locust.main: Starting web interface at http://:8089\n[2020-11-13 01:38:05,989] locust-master-6dd5cc46d4-xrqt6/INFO/locust.main: Starting Locust 1.1\n[2020-11-13 01:38:06,837] locust-master-6dd5cc46d4-xrqt6/INFO/locust.runners: Client 'locust-worker-bc7464db8-z84kp_324ebbc0df6f49c98c8198c8333195e1' reported as ready. Currently 1 clients ready to swarm.\n[2020-11-13 01:38:07,220] locust-master-6dd5cc46d4-xrqt6/INFO/locust.runners: Client 'locust-worker-bc7464db8-bs857_03b4f012581b4af2be62cf9912f45538' reported as ready. Currently 2 clients ready to swarm.\n```\n\nWe can see that the master has started (line 1 and 2) and the slaves \"volunteer\" to do some work (lines 3-4).\n\n# Search for public IP and port.\n\nYou need to know what are the public address the nodes are interfacing so that you can access to it:\n\n    \u003e kubectl get nodes -o wide |  awk {'print $1\" \" $2 \" \" $7'} | column -t\n    NAME                                         STATUS  EXTERNAL-IP\n    ip-x-x-x-x.ap-southeast-1.compute.internal   Ready   x.x.x.x\n    ip-y-y-y-y.ap-southeast-1.compute.internal   Ready   y.y.y.y\n\nYou also need to know what port are the NodePort service running on:\n\n    \u003e kubectl get service/locust-service\n    NAME             TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE\n    locust-service   NodePort   10.100.3.131   \u003cnone\u003e        8089:32535/TCP   26h\n\nGo to your EKS Cluster security group and open the port for external access.\n![](open-port.png)\n\nFrom there you access `http://x.x.x.x:32535` or `http://y.y.y.y:32535`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosesliao%2Fkubernetes-locust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmosesliao%2Fkubernetes-locust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosesliao%2Fkubernetes-locust/lists"}