From e8a940abea539915f8c31db3f32b39a8a32d0e80 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 23 Jan 2024 21:04:23 +0000 Subject: [PATCH] add support for persistence --- .../tandoor-recipes/templates/deployment.yaml | 20 ++++++++++++ .../tandoor-recipes/templates/pvc-media.yaml | 32 +++++++++++++++++++ .../tandoor-recipes/templates/pvc-static.yaml | 32 +++++++++++++++++++ charts/tandoor-recipes/values.yaml | 32 ++++++++++--------- 4 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 charts/tandoor-recipes/templates/pvc-media.yaml create mode 100644 charts/tandoor-recipes/templates/pvc-static.yaml diff --git a/charts/tandoor-recipes/templates/deployment.yaml b/charts/tandoor-recipes/templates/deployment.yaml index d469e92..6c761cb 100644 --- a/charts/tandoor-recipes/templates/deployment.yaml +++ b/charts/tandoor-recipes/templates/deployment.yaml @@ -65,6 +65,26 @@ spec: port: http resources: {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: static + mountPath: /opt/recipes/staticfiles + - name: media + mountPath: /opt/recipes/mediafiles + volumes: + - name: static + {{- if .Values.persistence.static.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.persistence.static.existingClaim }}{{ .Values.persistence.static.existingClaim }}{{- else }}{{ template "tandoor-recipes.fullname" . }}-static-pvc{{- end }} + {{- else }} + emptyDir: {} + {{- end }} + - name: media + {{- if .Values.persistence.media.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.persistence.media.existingClaim }}{{ .Values.persistence.media.existingClaim }}{{- else }}{{ template "tandoor-recipes.fullname" . }}-media-pvc{{- end }} + {{- else }} + emptyDir: {} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/tandoor-recipes/templates/pvc-media.yaml b/charts/tandoor-recipes/templates/pvc-media.yaml new file mode 100644 index 0000000..f6a2cc5 --- /dev/null +++ b/charts/tandoor-recipes/templates/pvc-media.yaml @@ -0,0 +1,32 @@ +{{- if .Values.persistence.media.enabled -}} +{{- if not .Values.persistence.media.existingClaim -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "tandoor-recipes.fullname" . }}-media-pvc + labels: + {{- include "tandoor-recipes.labels" . | nindent 4 }} + # app.kubernetes.io/name: {{ include "tandoor-recipes.name" . }} + # helm.sh/chart: {{ include "tandoor-recipes.chart" . }} + # app.kubernetes.io/instance: {{ .Release.Name }} + # app.kubernetes.io/managed-by: {{ .Release.Service }} + # app.kubernetes.io/component: app +{{- if .Values.persistence.media.annotations }} + annotations: +{{ toYaml .Values.persistence.media.annotations | indent 4 }} +{{- end }} +spec: + accessModes: + - {{ .Values.persistence.media.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.media.size | quote }} +{{- if .Values.persistence.media.storageClass }} +{{- if (eq "-" .Values.persistence.media.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.media.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/tandoor-recipes/templates/pvc-static.yaml b/charts/tandoor-recipes/templates/pvc-static.yaml new file mode 100644 index 0000000..316241f --- /dev/null +++ b/charts/tandoor-recipes/templates/pvc-static.yaml @@ -0,0 +1,32 @@ +{{- if .Values.persistence.static.enabled -}} +{{- if not .Values.persistence.static.existingClaim -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "tandoor-recipes.fullname" . }}-static-pvc + labels: + {{- include "tandoor-recipes.labels" . | nindent 4 }} + # app.kubernetes.io/name: {{ include "tandoor-recipes.name" . }} + # helm.sh/chart: {{ include "tandoor-recipes.chart" . }} + # app.kubernetes.io/instance: {{ .Release.Name }} + # app.kubernetes.io/managed-by: {{ .Release.Service }} + # app.kubernetes.io/component: app +{{- if .Values.persistence.static.annotations }} + annotations: +{{ toYaml .Values.persistence.static.annotations | indent 4 }} +{{- end }} +spec: + accessModes: + - {{ .Values.persistence.static.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.static.size | quote }} +{{- if .Values.persistence.static.storageClass }} +{{- if (eq "-" .Values.persistence.static.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.static.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/tandoor-recipes/values.yaml b/charts/tandoor-recipes/values.yaml index 92e0ed6..c8aa842 100644 --- a/charts/tandoor-recipes/values.yaml +++ b/charts/tandoor-recipes/values.yaml @@ -58,21 +58,23 @@ postgresql: recipes: secretKey: "" - persistence: - static: - enabled: false - existingClaim: "" - annotations: {} - accessMode: ReadWriteOnce - storageClass: "" - size: 1Gi - media: - enabled: false - existingClaim: "" - annotations: {} - accessMode: ReadWriteOnce - storageClass: "" - size: 1Gi + +persistence: + static: + enabled: false + existingClaim: "" + annotations: {} + accessMode: ReadWriteOnce + storageClass: "" + size: 1Gi + media: + enabled: false + existingClaim: "" + annotations: {} + accessMode: ReadWriteOnce + storageClass: "" + size: 1Gi + ingress: enabled: false className: ""