From 676bcf08d6203d764a7705fe434fcfd5936887c2 Mon Sep 17 00:00:00 2001 From: Max Roby Date: Sun, 19 Nov 2023 09:37:37 +0100 Subject: [PATCH] add option for existingClaim usage to master-statefulset, fix naming in volume-statefulset --- k8s/charts/seaweedfs/templates/_helpers.tpl | 9 +++++++++ .../seaweedfs/templates/master-statefulset.yaml | 13 ++++++++++++- .../seaweedfs/templates/volume-statefulset.yaml | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/k8s/charts/seaweedfs/templates/_helpers.tpl b/k8s/charts/seaweedfs/templates/_helpers.tpl index 611a2b4ef..8babbf93b 100644 --- a/k8s/charts/seaweedfs/templates/_helpers.tpl +++ b/k8s/charts/seaweedfs/templates/_helpers.tpl @@ -175,6 +175,15 @@ Inject extra environment vars in the format key:value, if populated {{- end -}} {{- end -}} +{{/* check if any Master existingClaim is defined */}} +{{- define "master.existing_claims" -}} +{{- if or (eq .Values.master.data.type "existingClaim") (eq .Values.master.logs.type "existingClaim") -}} +{{- printf "true" -}} +{{- else -}} +{{- printf "" -}} +{{- end -}} +{{- end -}} + {{/* check if any InitContainers exist for Volumes */}} {{- define "volume.initContainers_exists" -}} {{- if or (not (empty .Values.volume.dir_idx )) (not (empty .Values.volume.initContainers )) -}} diff --git a/k8s/charts/seaweedfs/templates/master-statefulset.yaml b/k8s/charts/seaweedfs/templates/master-statefulset.yaml index 110764735..1121f4754 100644 --- a/k8s/charts/seaweedfs/templates/master-statefulset.yaml +++ b/k8s/charts/seaweedfs/templates/master-statefulset.yaml @@ -213,7 +213,8 @@ spec: {{ tpl .Values.master.resources . | nindent 12 | trim }} {{- end }} {{- $hostpath_exists := include "master.hostpath_exists" . -}} - {{- if $hostpath_exists }} + {{- $existing_claims := include "master.existing_claims" . -}} + {{- if or ($hostpath_exists) ($existing_claims) }} volumes: {{- if eq .Values.master.logs.type "hostPath" }} - name: seaweedfs-master-log-volume @@ -221,12 +222,22 @@ spec: path: {{ .Values.master.logs.hostPathPrefix }}/logs/seaweedfs/master type: DirectoryOrCreate {{- end }} + {{- if eq .Values.master.logs.type "existingClaim" }} + - name: logs + persistentVolumeClaim: + claimName: {{ .Values.master.logs.claimName }} + {{- end }} {{- if eq .Values.master.data.type "hostPath" }} - name: data-{{ .Release.Namespace }} hostPath: path: {{ .Values.master.data.hostPathPrefix }}/seaweed-master/ type: DirectoryOrCreate {{- end }} + {{- if eq .Values.master.data.type "existingClaim" }} + - name: data + persistentVolumeClaim: + claimName: {{ .Values.master.data.claimName }} + {{- end }} - name: master-config configMap: name: {{ template "seaweedfs.name" . }}-master-config diff --git a/k8s/charts/seaweedfs/templates/volume-statefulset.yaml b/k8s/charts/seaweedfs/templates/volume-statefulset.yaml index 9e2f4f2c0..1ac17d9e8 100644 --- a/k8s/charts/seaweedfs/templates/volume-statefulset.yaml +++ b/k8s/charts/seaweedfs/templates/volume-statefulset.yaml @@ -239,7 +239,7 @@ spec: type: DirectoryOrCreate {{- end }} {{- if eq .Values.volume.idx.type "existingClaim" }} - - name: data + - name: idx persistentVolumeClaim: claimName: {{ .Values.volume.idx.claimName }} {{- end }} @@ -250,7 +250,7 @@ spec: type: DirectoryOrCreate {{- end }} {{- if eq .Values.volume.logs.type "existingClaim" }} - - name: data + - name: logs persistentVolumeClaim: claimName: {{ .Values.volume.data.claimName }} {{- end }}