diff --git a/kubernetes-manifests/loadgenerator.yaml b/kubernetes-manifests/loadgenerator.yaml index 7fa40a0..e81d4a6 100644 --- a/kubernetes-manifests/loadgenerator.yaml +++ b/kubernetes-manifests/loadgenerator.yaml @@ -3,21 +3,32 @@ kind: Deployment metadata: name: loadgenerator spec: + replicas: 1 template: metadata: labels: app: loadgenerator spec: + restartPolicy: Always initContainers: - name: wait-frontend image: alpine:3.6 - command: ['sh', '-c', 'until wget -qO- "http://${FRONTEND_ADDR}"; do echo "waiting for ${FRONTEND_ADDR}"; sleep 2; done;'] + command: ['sh', '-c', 'set -x; apk add --no-cache curl; + until curl -f "http://${FRONTEND_ADDR}"; do + echo "waiting for http://${FRONTEND_ADDR}"; + sleep 2; + done;'] + env: + - name: FRONTEND_ADDR + value: "frontend:80" containers: - - name: server + - name: main image: loadgenerator env: - name: FRONTEND_ADDR - value: "frontend:8080" + value: "frontend:80" + - name: USERS + value: "1" resources: requests: cpu: 100m diff --git a/src/loadgenerator/Dockerfile b/src/loadgenerator/Dockerfile index 69cf7b3..be8e00b 100644 --- a/src/loadgenerator/Dockerfile +++ b/src/loadgenerator/Dockerfile @@ -4,4 +4,4 @@ COPY requirements.txt . RUN pip install -r requirements.txt COPY . . -ENTRYPOINT locust --host="http://${FRONTEND_ADDR}" --no-web -c=10 +ENTRYPOINT ./loadgen.sh diff --git a/src/loadgenerator/loadgen.sh b/src/loadgenerator/loadgen.sh new file mode 100755 index 0000000..5021e29 --- /dev/null +++ b/src/loadgenerator/loadgen.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +if [[ -z "${FRONTEND_ADDR}" ]]; then + echo >&2 "FRONTEND_ADDR not specified" + exit 1 +fi + +set -x +locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}" diff --git a/src/loadgenerator/locustfile.py b/src/loadgenerator/locustfile.py index f56beba..012cd48 100644 --- a/src/loadgenerator/locustfile.py +++ b/src/loadgenerator/locustfile.py @@ -63,4 +63,4 @@ class UserBehavior(TaskSet): class WebsiteUser(HttpLocust): task_set = UserBehavior min_wait = 1000 - max_wait = 2000 + max_wait = 10000