From 4f4af04a74823524b7a7feae836bde98cc21d87d Mon Sep 17 00:00:00 2001 From: alfredeen Date: Mon, 29 Apr 2024 12:32:48 +0200 Subject: [PATCH] Added basic auth to Locust web UI --- .gitignore | 3 +++ README.md | 24 +++++++++++++++++++++++- manifests/ingress.yaml | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 90ae6d7..536e017 100644 --- a/.gitignore +++ b/.gitignore @@ -132,6 +132,9 @@ dmypy.json # Cython debug symbols cython_debug/ +# Locust deployment +locust-auth + # Locust output files source/reports/* !source/reports/.gitkeep diff --git a/README.md b/README.md index accb6a0..d78f4a6 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,6 @@ $ chmod +x run_test_plan.sh $ ./run_test_plan.sh ``` - ## Use a custom built docker image cd ./source @@ -158,3 +157,26 @@ $ ./run_test_plan.sh docker build -t serve-load-testing . docker run -p 8089:8089 serve-load-testing + +## Deploy to kubernetes + +### Using ArgoCD + +Create a new ArgoCD app using the application manifest ./argocd/application.yaml + +### Using CLI kubectl + +Create a deployment named locust-deployment in a new namespace locust: + + kubectl apply -f ./manifests --force + +### Create a secret for the Locust web UI + +Create a secret named locust-ui-secret. +Required apache2-utils + + sudo apt install apache2-utils + + htpasswd -bc locust-auth locust + + kubectl -n locust create secret generic locust-ui-secret --from-file=locust-auth diff --git a/manifests/ingress.yaml b/manifests/ingress.yaml index 7ca91b8..a75fcf0 100644 --- a/manifests/ingress.yaml +++ b/manifests/ingress.yaml @@ -6,6 +6,9 @@ metadata: annotations: kubernetes.io/ingress.class: "nginx" cert-manager.io/cluster-issuer: "letsencrypt-issuer" + nginx.ingress.kubernetes.io/auth-type: basic + nginx.ingress.kubernetes.io/auth-secret: locust-ui-secret + nginx.ingress.kubernetes.io/auth-realm: "Protected area" spec: rules: - host: locust.serve-dev.scilifelab.se #localhost