From b6d541f44c2f00fce2a1436023eb5e30d62ba872 Mon Sep 17 00:00:00 2001 From: Voro <107838162+VoroAndjaro@users.noreply.github.com> Date: Thu, 2 May 2024 14:12:55 +0200 Subject: [PATCH] Add tolerations and local storage to the deployment (#26) * Add tolerations and local storage to the deployment Signed-off-by: Voro * Update helm-charts/inbucket/Chart.yaml Co-authored-by: Carlos Tadeu Panato Junior Signed-off-by: Voro * Fix persistence conditional when no persistence values are set Signed-off-by: Voro --------- Signed-off-by: Voro Co-authored-by: Carlos Tadeu Panato Junior --- helm-charts/inbucket/Chart.yaml | 2 +- helm-charts/inbucket/templates/_helpers.tpl | 7 +++++++ helm-charts/inbucket/templates/deployment.yaml | 17 +++++++++++++++++ helm-charts/inbucket/templates/pvc.yaml | 18 ++++++++++++++++++ helm-charts/inbucket/values.yaml | 7 +++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 helm-charts/inbucket/templates/pvc.yaml diff --git a/helm-charts/inbucket/Chart.yaml b/helm-charts/inbucket/Chart.yaml index b5d6916..b51ca5f 100644 --- a/helm-charts/inbucket/Chart.yaml +++ b/helm-charts/inbucket/Chart.yaml @@ -3,7 +3,7 @@ description: Disposable webmail server (similar to Mailinator) with built in SMT name: inbucket type: application appVersion: 3.0.0 -version: 2.2.2 +version: 2.3.0 keywords: - inbucket - mail diff --git a/helm-charts/inbucket/templates/_helpers.tpl b/helm-charts/inbucket/templates/_helpers.tpl index 2a92b3d..3333843 100644 --- a/helm-charts/inbucket/templates/_helpers.tpl +++ b/helm-charts/inbucket/templates/_helpers.tpl @@ -69,3 +69,10 @@ Return if ingress supports pathType. {{- define "inbucket.ingress.supportsPathType" -}} {{- or (eq (include "inbucket.ingress.isStable" .) "true") (and (eq (include "inbucket.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} {{- end -}} + +{{/* +Return if persistence is enabled. +*/}} +{{- define "inbucket.persistenceEnabled" -}} + {{- and ( and ( hasKey .Values "persistence" ) ( hasKey .Values.persistence "enabled" ) ) ( eq .Values.persistence.enabled true ) -}} +{{- end -}} diff --git a/helm-charts/inbucket/templates/deployment.yaml b/helm-charts/inbucket/templates/deployment.yaml index ab2ab2b..be454a5 100644 --- a/helm-charts/inbucket/templates/deployment.yaml +++ b/helm-charts/inbucket/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- $persistence := eq (include "inbucket.persistenceEnabled" .) "true" -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -54,7 +55,23 @@ spec: timeoutSeconds: 5 resources: {{ toYaml .Values.resources | indent 12 }} + {{- if $persistence }} + volumeMounts: + - mountPath: {{ .Values.persistence.path }} + name: {{ include "inbucket.fullname" . }} + readOnly: false + {{- end }} {{- if .Values.nodeSelector }} nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }} {{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 6 }} + {{- end }} + {{- if $persistence}} + volumes: + - name: {{ include "inbucket.fullname" . }} + persistentVolumeClaim: + claimName: {{ include "inbucket.fullname" . }} + {{- end }} diff --git a/helm-charts/inbucket/templates/pvc.yaml b/helm-charts/inbucket/templates/pvc.yaml new file mode 100644 index 0000000..c96d5af --- /dev/null +++ b/helm-charts/inbucket/templates/pvc.yaml @@ -0,0 +1,18 @@ +{{- if eq (include "inbucket.persistenceEnabled" .) "true" }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "inbucket.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "inbucket.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + helm.sh/chart: {{ include "inbucket.chart" . }} +spec: + accessModes: + - {{ default .Values.persistence.accessMode "ReadWriteOnce" }} + resources: + requests: + storage: {{ .Values.persistence.size }} + storageClassName: {{ .Values.persistence.className }} +{{- end }} diff --git a/helm-charts/inbucket/values.yaml b/helm-charts/inbucket/values.yaml index 6469864..abe6380 100644 --- a/helm-charts/inbucket/values.yaml +++ b/helm-charts/inbucket/values.yaml @@ -74,3 +74,10 @@ ingress: podAnnotations: {} resources: {} + +persistence: + enabled: false + path: /storage + size: 1Gi + className: + accessMode: ReadWriteOnce