# Locust load-test plumbing for Lab 10. # # Why in-cluster: `kubectl port-forward svc/gateway` targets ONE pod for # the whole session. To load-test all 5 gateway replicas through # kube-proxy, the load generator itself must run inside the cluster. # # The ConfigMap that feeds locustfile.py to the Locust pod is NOT declared # inline here — you build it from `labs/lab10/locustfile.py` so the actual # Python file stays syntax-highlighted and editable in your fork: # # cp labs/lab10/locustfile.py locustfile.py # commit it to your fork # kubectl create configmap locustfile \ # --from-file=locustfile.py=locustfile.py \ # --dry-run=client -o yaml | kubectl apply -f - # re-run after every edit # # This file contains only the Job template. You instantiate one per load # level (load-10, load-50, load-100, load-200) by copying, renaming, and # editing the -u / -r / -t args. # # Apply the template to verify nothing is syntactically broken: # kubectl apply -f labs/lab10/locust-runner.yaml apiVersion: batch/v1 kind: Job metadata: # TEMPLATE — rename per run (load-10, load-50, …). K8s requires lowercase. name: load-template spec: backoffLimit: 0 ttlSecondsAfterFinished: 600 template: spec: restartPolicy: Never containers: - name: locust image: locustio/locust:2.43.4 command: ["locust"] args: - "-f" - "/mnt/locust/locustfile.py" - "--host=http://gateway:8080" - "--headless" - "-u" - "10" # ← users - "-r" - "2" # ← ramp-up per second - "-t" - "60s" # ← duration - "--only-summary" volumeMounts: - name: locustfile mountPath: /mnt/locust volumes: - name: locustfile configMap: name: locustfile