Skip to content

Commit

Permalink
Authentication in UI (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredeen authored Apr 29, 2024
1 parent 0df4af4 commit 1c1ddfd
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ dmypy.json
# Cython debug symbols
cython_debug/

# Locust deployment
locust-auth

# Locust output files
source/reports/*
!source/reports/.gitkeep
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,33 @@ $ chmod +x run_test_plan.sh
$ ./run_test_plan.sh
```


## Use a custom built docker image

cd ./source

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 <pwd>

kubectl -n locust create secret generic locust-ui-secret --from-file=locust-auth
16 changes: 16 additions & 0 deletions argocd/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: serve-locust
spec:
destination:
namespace: locust
server: 'https://kubernetes.default.svc'
project: default
source:
repoURL: https://github.com/ScilifelabDataCentre/serve-load-testing
path: manifests
targetRevision: develop
syncPolicy:
syncOptions:
- CreateNamespace=true
22 changes: 22 additions & 0 deletions manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: locust-deployment
namespace: locust
spec:
replicas: 1
selector:
matchLabels:
app: locust
template:
metadata:
labels:
app: locust
annotations:
statefulset.kubernetes.io/pod-name: locust
spec:
containers:
- name: locust
image: ghcr.io/scilifelabdatacentre/serve-load-testing:main-20240419-1108
ports:
- containerPort: 8089
28 changes: 28 additions & 0 deletions manifests/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: locust-ingress
namespace: locust
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
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: locust-service
port:
number: 80 #8089
#ingressClassName: nginx
tls:
- hosts:
- locust.serve-dev.scilifelab.se
secretName: locust-tls
4 changes: 4 additions & 0 deletions manifests/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: locust
13 changes: 13 additions & 0 deletions manifests/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: locust-service
namespace: locust
spec:
selector:
app: locust
ports:
- protocol: TCP
port: 80 #8089
targetPort: 8089
type: ClusterIP #NodePort

0 comments on commit 1c1ddfd

Please sign in to comment.