k8s configuration, Makefile to help build images, changes to dockerfiles
This commit is contained in:
Родитель
08c004166d
Коммит
190df0dba4
|
@ -0,0 +1,21 @@
|
|||
.PHONY: all build_base build_web build_worker push_base push_web push_worker
|
||||
|
||||
all: build_base push_base build_web push_web build_worker push_worker
|
||||
|
||||
build_base:
|
||||
docker build -f ./dockerfiles/Dockerfile.base -t cade/donate-locust:base-latest .
|
||||
|
||||
push_base:
|
||||
docker push cade/donate-locust:base-latest
|
||||
|
||||
build_web:
|
||||
docker build -f ./dockerfiles/Dockerfile.web -t cade/donate-locust:web-latest .
|
||||
|
||||
push_web:
|
||||
docker push cade/donate-locust:web-latest
|
||||
|
||||
build_worker:
|
||||
docker build -f ./dockerfiles/Dockerfile.worker -t cade/donate-locust:worker-latest .
|
||||
|
||||
push_worker:
|
||||
docker push cade/donate-locust:worker-latest
|
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# adapted from https://github.com/locustio/locust/blob/246ec42e59fe38f0d27b8ea752209d838e27b898/docker_start.sh
|
||||
|
||||
if [ -z "${TARGET_URL}" ]; then
|
||||
echo "ERROR: TARGET_URL is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOCUST_MODE="${LOCUST_MODE:=standalone}"
|
||||
LOCUST_OPTS="-f ./stress_test.py -H ${TARGET_URL}"
|
||||
|
||||
if [ "${LOCUST_MODE}" = "leader"]; then
|
||||
LOCUST_OPTS="${LOCUST_OPTS} --master"
|
||||
elif [ "${LOCUST_MODE}" = "follower" ]; then
|
||||
if [ -z "$LOCUST_LEADER_HOST" ]; then
|
||||
echo "ERROR: LOCUST_LEADER_HOST is not configured. A follower node requires a leader node." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOCUST_OPTS="${LOCUST_OPTS} --slave --master-host=${LOCUST_LEADER_HOST} --master-port=${LOCUST_LEADER_PORT:-5557}"
|
||||
fi
|
||||
|
||||
echo "starting Locust"
|
||||
echo "$ locust ${LOCUST_OPTS}"
|
||||
|
||||
locust ${LOCUST_OPTS}
|
|
@ -11,15 +11,14 @@ RUN pip install virtualenv
|
|||
|
||||
RUN virtualenv venv
|
||||
|
||||
COPY requirements.txt .
|
||||
COPY ./requirements.txt .
|
||||
|
||||
RUN . /app/venv/bin/activate && pip install -r requirements.txt
|
||||
|
||||
COPY stress_test.py .
|
||||
COPY docker_start.sh .
|
||||
COPY ./stress_test.py .
|
||||
COPY ./scripts/start_follower.sh ./scripts/
|
||||
|
||||
|
||||
RUN useradd -ms /bin/bash locust
|
||||
|
||||
USER locust
|
||||
|
||||
CMD . /app/venv/bin/activate && ./docker_start.sh
|
||||
USER locust
|
|
@ -0,0 +1,5 @@
|
|||
FROM cade/donate-locust:base-latest
|
||||
|
||||
COPY ./scripts/start_leader.sh .
|
||||
|
||||
CMD . /app/venv/bin/activate && ./start_leader.sh
|
|
@ -0,0 +1,6 @@
|
|||
FROM cade/donate-locust:base-latest
|
||||
|
||||
|
||||
COPY ./scripts/start_follower.sh .
|
||||
|
||||
CMD . /app/venv/bin/activate && ./start_follower.sh
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: donate-locust
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: locust-leader
|
||||
ports:
|
||||
- port: 5557
|
||||
name: comm
|
||||
- port: 5558
|
||||
name: comm-plus-1
|
||||
- port: 8089
|
||||
name: web-ui
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: donate-locust-config
|
||||
data:
|
||||
targeturl: 'https://donate-wagtail-staging.herokuapp.com'
|
|
@ -0,0 +1,37 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: locust-deployment-follower
|
||||
labels:
|
||||
app: locust-follower
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: locust-follower
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: locust-follower
|
||||
spec:
|
||||
containers:
|
||||
- name: locust-follower
|
||||
image: cade/donate-locust@sha256:bd33eaea3faafa58b682b38b4277287a12ec0b2d7bce1c34afdc4aade5164136
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: TARGET_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: donate-locust-config
|
||||
key: targeturl
|
||||
- name: LOCUST_LEADER_HOST
|
||||
value: donate-locust
|
||||
- name: LOCUST_LEADER_PORT
|
||||
value: '5557'
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
|
@ -0,0 +1,37 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: locust-deployment-leader
|
||||
labels:
|
||||
app: locust-leader
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: locust-leader
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: locust-leader
|
||||
spec:
|
||||
containers:
|
||||
- name: locust-leader
|
||||
image: cade/donate-locust@sha256:24ea47dbea89ad963cb547845e6c33e9a590f11377cdcab8e431ce3d5d0bd4f2
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8089
|
||||
- containerPort: 5557
|
||||
- containerPort: 5558
|
||||
env:
|
||||
- name: TARGET_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: donate-locust-config
|
||||
key: targeturl
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# adapted from https://github.com/locustio/locust/blob/246ec42e59fe38f0d27b8ea752209d838e27b898/docker_start.sh
|
||||
|
||||
if [ -z "${TARGET_URL}" ]; then
|
||||
echo "ERROR: TARGET_URL is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$LOCUST_LEADER_HOST" ]; then
|
||||
echo "ERROR: LOCUST_LEADER_HOST is not configured. A follower node requires a leader node." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOCUST_OPTS="-f ./stress_test.py -H ${TARGET_URL} --slave --master-host=${LOCUST_LEADER_HOST} --master-port=${LOCUST_LEADER_PORT:-5557}"
|
||||
|
||||
echo "starting Locust"
|
||||
echo "$ locust ${LOCUST_OPTS}"
|
||||
|
||||
locust ${LOCUST_OPTS}
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# adapted from https://github.com/locustio/locust/blob/246ec42e59fe38f0d27b8ea752209d838e27b898/docker_start.sh
|
||||
|
||||
if [ -z "${TARGET_URL}" ]; then
|
||||
echo "ERROR: TARGET_URL is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOCUST_OPTS="-f ./stress_test.py -H ${TARGET_URL} --master"
|
||||
|
||||
echo "starting Locust"
|
||||
echo "$ locust ${LOCUST_OPTS}"
|
||||
|
||||
locust ${LOCUST_OPTS}
|
Загрузка…
Ссылка в новой задаче