diff --git a/k8s/deluge-service.yaml b/k8s/deluge-service.yaml new file mode 100644 index 0000000..775fbbe --- /dev/null +++ b/k8s/deluge-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: deluge-service + namespace: codex-benchmarks + labels: + app: deluge-nodes +spec: + clusterIP: None + selector: + app: deluge-nodes + ports: + - port: 6890 + name: rpc + - port: 6891 + name: listen-1 + - port: 6892 + name: listen-2 \ No newline at end of file diff --git a/k8s/deluge-statefulset.yaml b/k8s/deluge-statefulset.yaml index 46aaacb..83dd851 100644 --- a/k8s/deluge-statefulset.yaml +++ b/k8s/deluge-statefulset.yaml @@ -35,7 +35,12 @@ spec: command: [ "/bin/bash", "--login", "-c" ] args: - | + # Sadly we can't mount a subpath, so need add the correct prefix + # into all of the config directories. export DELUGE_CONFIG_DIR=/var/lib/deluge/${CLIENT_POD_NAME} + export DELUGE_DOWNLOAD_DIR=${DELUGE_CONFIG_DIR}/downloads + export DELUGE_TORRENTFILE_DIR=${DELUGE_CONFIG_DIR}/downloads + export DELUGE_PLUGINS_DIR=${DELUGE_CONFIG_DIR}/plugins # Makes sure there's no previous garbage in there. rm -rf ${DELUGE_CONFIG_DIR} diff --git a/k8s/deploy-order.txt b/k8s/deploy-order.txt new file mode 100644 index 0000000..edcf6dd --- /dev/null +++ b/k8s/deploy-order.txt @@ -0,0 +1,7 @@ +namespace.yaml +deluge-pvc.yaml +deluge-service.yaml +tracker-deployment.yaml +tracker-service.yaml +deluge-statefulset.yaml +testrunner-job.yaml diff --git a/k8s/run.sh b/k8s/run.sh new file mode 100755 index 0000000..3a011bd --- /dev/null +++ b/k8s/run.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -e + +function on_interrupt () { + read -p "CTRL+C pressed. Do you want to stop the test runner as well? [y/N] " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "Deleting experiment namespace..." + kubectl delete namespace codex-benchmarks + fi +} + +trap on_interrupt INT + +echo " * Clearing previous deployments" +kubectl delete namespace codex-benchmarks || true + +echo " * Deploying manifests" +while read -r resource; do + kubectl apply -f "${resource}" +done < deploy-order.txt + +echo " * Awaiting for test runner to start" +kubectl wait --for=condition=Ready --selector=app=testrunner pod -n codex-benchmarks --timeout=30s + +echo " * Attaching to test runner logs" +TESTRUNNER_POD=$(kubectl get pods -n codex-benchmarks -l app=testrunner -o jsonpath="{.items[0].metadata.name}") +if [ -z "${TESTRUNNER_POD}" ]; then + echo "Testrunner pod not found" + exit 1 +fi + +kubectl logs -f "${TESTRUNNER_POD}" -n codex-benchmarks diff --git a/k8s/testrunner-job.yaml b/k8s/testrunner-job.yaml new file mode 100644 index 0000000..09e2bf5 --- /dev/null +++ b/k8s/testrunner-job.yaml @@ -0,0 +1,55 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: testrunner + namespace: codex-benchmarks + labels: + app: testrunner +spec: + template: + metadata: + labels: + app: testrunner + spec: + containers: + - name: testrunner + image: codexstorage/bittorrent-benchmarks:latest + imagePullPolicy: Always + args: [ "run", "deluge_experiment" ] + env: + - name: NETWORK_SIZE + value: "5" + - name: SEEDERS + value: "1" + - name: REPETITIONS + value: "1" + - name: FILE_SIZE + value: "52428800" + - name: TRACKER_ANNOUNCE_URL + value: "http://tracker-service.codex-benchmarks.svc.cluster.local:8000/announce" + - name: SHARED_VOLUME_PATH + value: "/opt/bittorrent-benchmarks/volume" + - name: DELUGE_STATEFULSET + value: "deluge-nodes" + - name: DELUGE_SERVICE + value: "deluge-service" + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumeMounts: + - name: benchmark-volume + mountPath: /opt/bittorrent-benchmarks/volume + resources: + requests: + cpu: "1" + memory: "2Gi" + limits: + cpu: "1" + memory: "2Gi" + volumes: + - name: benchmark-volume + persistentVolumeClaim: + claimName: deluge-pvc + restartPolicy: Never + backoffLimit: 0 diff --git a/k8s/tracker-service.yaml b/k8s/tracker-service.yaml index 07ad886..83578bd 100644 --- a/k8s/tracker-service.yaml +++ b/k8s/tracker-service.yaml @@ -12,4 +12,4 @@ spec: targetPort: 8000 protocol: TCP selector: - app: tracker \ No newline at end of file + app: bittorrent-tracker \ No newline at end of file