From b2acaab7ae296046aa17dcd87cdb79f03b03e9be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de>
Date: Wed, 3 Nov 2021 17:21:35 +0100
Subject: [PATCH] Create PVC with Helm

---
 helm/templates/_helpers.tpl                    |  7 +++++++
 .../theodolite/results-volume/pvc.yaml         | 18 ++++++++++++++++++
 .../theodolite/theodolite-operator.yaml        |  2 +-
 helm/values.yaml                               |  7 +++++--
 4 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 helm/templates/theodolite/results-volume/pvc.yaml

diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl
index f59f74d36..4aebdca5d 100644
--- a/helm/templates/_helpers.tpl
+++ b/helm/templates/_helpers.tpl
@@ -60,3 +60,10 @@ Create the name of the service account to use
 {{- default "default" .Values.serviceAccount.name }}
 {{- end }}
 {{- end }}
+
+{{/*
+Create the name of the results volume to use
+*/}}
+{{- define "theodolite.resultsClaimName" -}}
+{{- default (include "theodolite.fullname" .)-results .Values.operator.resultsVolume.existingClaim }}
+{{- end }}
diff --git a/helm/templates/theodolite/results-volume/pvc.yaml b/helm/templates/theodolite/results-volume/pvc.yaml
new file mode 100644
index 000000000..3f2340803
--- /dev/null
+++ b/helm/templates/theodolite/results-volume/pvc.yaml
@@ -0,0 +1,18 @@
+{{- if and .Values.operator.resultsVolume.enabled (not .Values.operator.resultsVolume.existingClaim)) -}}
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: {{ include "theodolite.resultsClaimName" . }}
+spec:
+  {{- if .Values.operator.resultsVolume.storageClassName }}
+  storageClassName: {{ .Values.operator.resultsVolume.storageClassName }}
+  {{- end }}
+  accessModes:
+    - ReadWriteOnce
+    {{- range .Values.operator.resultsVolume.accessModes }}
+    - {{ . | quote }}
+    {{- end }}
+  resources:
+    requests:
+      storage: {{ .Values.operator.resultsVolume.size | quote }}
+{{- end }}
\ No newline at end of file
diff --git a/helm/templates/theodolite/theodolite-operator.yaml b/helm/templates/theodolite/theodolite-operator.yaml
index 3487b9a4f..6e30eb57f 100644
--- a/helm/templates/theodolite/theodolite-operator.yaml
+++ b/helm/templates/theodolite/theodolite-operator.yaml
@@ -81,7 +81,7 @@ spec:
       {{- if .Values.operator.resultsVolume.enabled }}
       - name: theodolite-pv-storage
         persistentVolumeClaim:
-          claimName: {{ .Values.operator.resultsVolume.persistentVolumeClaim.name | quote }}
+          claimName: {{ include "theodolite.resultsClaimName" . | quote }}
       {{- end }}
       - name: benchmark-resources-uc1-kstreams
         configMap:
diff --git a/helm/values.yaml b/helm/values.yaml
index 571cdd629..95ec9babd 100644
--- a/helm/values.yaml
+++ b/helm/values.yaml
@@ -259,8 +259,11 @@ operator:
 
   resultsVolume:
     enabled: true
-    persistentVolumeClaim:
-      name: theodolite-pv-claim
+    # existingClaim:
+    # storageClassName:
+    accessModes:
+      - ReadWriteOnce
+    size: 1Gi
     accessSidecar:
       enabled: true
       image: busybox
-- 
GitLab