From e8cd20b9f55477b47654350c0c8c8f4bb1562e00 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Thu, 9 Nov 2023 17:42:34 +0100 Subject: [PATCH] fix: add persistent volume claim --- templates/deployment.yaml | 19 ++++++++++++++----- templates/persistentVolumeClaim.yaml | 24 ++++++++++++++++++++++++ values.yaml | 18 ++++++++---------- 3 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 templates/persistentVolumeClaim.yaml diff --git a/templates/deployment.yaml b/templates/deployment.yaml index dba4b1d..41408b0 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -48,9 +48,10 @@ spec: {{- toYaml .Values.resources | nindent 12 }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - {{- with .Values.volumeMounts }} - volumeMounts: - {{- toYaml . | nindent 8 }} + {{- if .Values.persistentStorage.enabled }} + volumes: + - name: config + mountPath: /config {{- end }} {{- with .Values.imagePullSecrets }} imagePullSecrets: @@ -69,7 +70,15 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- if .Values.persistentStorage.enabled }} volumes: - {{- with .Values.volumes }} - {{- toYaml . | nindent 6 }} + {{- if .Values.persistentStorage.existingClaim }} + - name: config + persistentVolumeClaim: + claimName: {{ .Values.persistentStorage.existingClaim }} + {{- else }} + - name: config + persistentVolumeClaim: + claimName: {{ include "homeassistant.fullname" . }} + {{- end }} {{- end }} diff --git a/templates/persistentVolumeClaim.yaml b/templates/persistentVolumeClaim.yaml new file mode 100644 index 0000000..716f878 --- /dev/null +++ b/templates/persistentVolumeClaim.yaml @@ -0,0 +1,24 @@ +{{- if .Values.persistentStorage.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + {{- with .Values.persistentStorage.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + name: {{ include "homeassistant.fullname" . }} + labels: + {{- include "homeassistant.labels" . | nindent 4 }} + {{- with .Values.persistentStorage.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + accessModes: + - ReadWriteOnce + {{- if .Values.persistentStorage.storageClass }} + storageClassName: {{ .Values.persistentStorage.storageClass }} + {{- end }} + resources: + requests: + storage: {{ required "Require size of persistent volume claim" .Values.persistentStorage.size }} +{{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 8c9876a..8b8a076 100644 --- a/values.yaml +++ b/values.yaml @@ -37,6 +37,14 @@ ingress: nodeSelector: {} +persistentStorage: + enabled: false + existingClaim: "" + annotations: {} + labels: {} + storageClass: + size: 15Gi + podAnnotations: {} podPriorityClassName: "" @@ -70,13 +78,3 @@ service: port: 8123 tolerations: [] - -volumeMounts: [] -# - name: config -# mountPath: /config - -volumes: [] -# - name: config -# hostPath: -# path: /etc/homeassistant -# type: DirectoryOrCreate