From 5aad40b6ab4a3e10e4662931e00a109cb8277953 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de>
Date: Fri, 20 Nov 2020 18:04:48 +0100
Subject: [PATCH] Enable volumes in the theodolite script

Add persistenVolume and persistentVolumeClaim to have a persistent
storage for the resulst of the theodolite job.
---
 .../infrastructure/kubernetes/volume.yaml     | 26 ++++++++
 execution/theodolite.yaml                     | 65 +++++++++++--------
 2 files changed, 63 insertions(+), 28 deletions(-)
 create mode 100644 execution/infrastructure/kubernetes/volume.yaml

diff --git a/execution/infrastructure/kubernetes/volume.yaml b/execution/infrastructure/kubernetes/volume.yaml
new file mode 100644
index 000000000..52000d293
--- /dev/null
+++ b/execution/infrastructure/kubernetes/volume.yaml
@@ -0,0 +1,26 @@
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: theodolite-pv-volume
+  labels:
+    type: local
+spec:
+  storageClassName: theodolite
+  capacity:
+    storage: 100m
+  accessModes:
+    - ReadWriteOnce
+  hostPath:
+    path: "</your/path/to/results/folder>"
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: theodolite-pv-claim
+spec:
+  storageClassName: theodolite
+  accessModes:
+    - ReadWriteOnce
+  resources:
+    requests:
+      storage: 100m
diff --git a/execution/theodolite.yaml b/execution/theodolite.yaml
index c083d327e..1c1ba6a1f 100644
--- a/execution/theodolite.yaml
+++ b/execution/theodolite.yaml
@@ -5,35 +5,44 @@ metadata:
 spec:
   template:
     spec:
+      volumes:
+      - name: theodolite-pv-storage
+        persistentVolumeClaim:
+          claimName: theodolite-pv-claim
       containers:
-      - name: theodolite
-        image: bvonheid/theodolite:latest
-        # imagePullPolicy: Never # Used to pull "own" local image
-        env:
-        - name: UC
-          value: "1"
-        - name: LOADS
-          value: "13206, 19635"
-        - name: INSTANCES
-          value: "1, 2"
-        - name: DURATION
-          value: "3"
-        - name: PARTITIONS
-          value: "30"
-        # - name: COMMIT_MS
-        #   value: ""
-        # - name: SEARCH_STRATEGY
-        #   value: ""
-        # - name: CPU_LIMIT
-        #   value: ""
-        # - name: MEMORY_LIMIT
-        #   value: ""
-        - name: PROMETHEUS_BASE_URL
-          value: "http://prometheus-operated:9090"
-        # - name: NAMESPACE
-        #   value: "default"
-        - name: PYTHONUNBUFFERED
-          value: "1"
+        - name: theodolite
+          image: bvonheid/theodolite:latest
+          # imagePullPolicy: Never # Used to pull "own" local image
+          env:
+            - name: UC
+              value: "1"
+            - name: LOADS
+              value: "13206, 19635"
+            - name: INSTANCES
+              value: "1, 2"
+            - name: DURATION
+              value: "3"
+            - name: PARTITIONS
+              value: "30"
+            # - name: COMMIT_MS
+            #   value: ""
+            # - name: SEARCH_STRATEGY
+            #   value: ""
+            # - name: CPU_LIMIT
+            #   value: ""
+            # - name: MEMORY_LIMIT
+            #   value: ""
+            - name: PROMETHEUS_BASE_URL
+              value: "http://prometheus-operated:9090"
+            # - name: NAMESPACE
+            #   value: "default"
+            - name: RESULT_PATH
+              value: "results"
+            - name: PYTHONUNBUFFERED
+              value: "1"
+          volumeMounts:
+            - mountPath: "/app/results"
+              name: theodolite-pv-storage
       restartPolicy: Never
   backoffLimit: 4
 
-- 
GitLab