diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 5f56775..8d8c4ec 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -83,6 +83,28 @@ Create the name of the service account to use {{- end }} {{- end }} +{{/* +Create the name of the assets persistent volume to use +*/}} +{{- define "mastodon.pvc.assets" -}} +{{- if .Values.mastodon.persistence.assets.existingClaim }} + {{- printf "%s" (tpl .Values.mastodon.persistence.assets.existingClaim $) -}} +{{- else -}} + {{- printf "%s-assets" (include "common.names.fullname" .) -}} +{{- end -}} +{{- end -}} + +{{/* +Create the name of the system persistent volume to use +*/}} +{{- define "mastodon.pvc.system" -}} +{{- if .Values.mastodon.persistence.system.existingClaim }} + {{- printf "%s" (tpl .Values.mastodon.persistence.system.existingClaim $) -}} +{{- else -}} + {{- printf "%s-system" (include "common.names.fullname" .) -}} +{{- end -}} +{{- end -}} + {{/* Create a default fully qualified name for dependent services. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). diff --git a/templates/cronjob-media-remove.yaml b/templates/cronjob-media-remove.yaml index 33229a8..e73e76d 100644 --- a/templates/cronjob-media-remove.yaml +++ b/templates/cronjob-media-remove.yaml @@ -36,10 +36,10 @@ spec: volumes: - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-assets + claimName: {{ template "mastodon.pvc.assets" . }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-system + claimName: {{ template "mastodon.pvc.system" . }} {{- end }} containers: - name: {{ include "mastodon.fullname" . }}-media-remove diff --git a/templates/deployment-sidekiq.yaml b/templates/deployment-sidekiq.yaml index f90b53a..82e045b 100644 --- a/templates/deployment-sidekiq.yaml +++ b/templates/deployment-sidekiq.yaml @@ -67,10 +67,10 @@ spec: {{- if (not $context.Values.mastodon.s3.enabled) }} - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" $context }}-assets + claimName: {{ template "mastodon.pvc.assets" $context }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" $context }}-system + claimName: {{ template "mastodon.pvc.system" $context }} {{- end }} {{- include "mastodon.statsdExporterVolume" $ | indent 8 }} {{- if dig "customDatabaseConfigYml" "configMapRef" "name" false . }} diff --git a/templates/deployment-web.yaml b/templates/deployment-web.yaml index b1bb0b8..12d2e96 100644 --- a/templates/deployment-web.yaml +++ b/templates/deployment-web.yaml @@ -46,10 +46,10 @@ spec: {{- if (not .Values.mastodon.s3.enabled) }} - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-assets + claimName: {{ template "mastodon.pvc.assets" . }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-system + claimName: {{ template "mastodon.pvc.system" . }} {{- end }} {{- include "mastodon.statsdExporterVolume" $ | indent 8 }} {{- if .Values.mastodon.web.customDatabaseConfigYml.configMapRef.name }} diff --git a/templates/job-assets-precompile.yaml b/templates/job-assets-precompile.yaml index 3458fea..29b9d31 100644 --- a/templates/job-assets-precompile.yaml +++ b/templates/job-assets-precompile.yaml @@ -37,10 +37,10 @@ spec: volumes: - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-assets + claimName: {{ template "mastodon.pvc.assets" . }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-system + claimName: {{ template "mastodon.pvc.system" . }} {{- end }} containers: - name: {{ include "mastodon.fullname" . }}-assets-precompile diff --git a/templates/job-chewy-upgrade.yaml b/templates/job-chewy-upgrade.yaml index 33e9bf9..0947f47 100644 --- a/templates/job-chewy-upgrade.yaml +++ b/templates/job-chewy-upgrade.yaml @@ -37,10 +37,10 @@ spec: volumes: - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-assets + claimName: {{ template "mastodon.pvc.assets" . }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-system + claimName: {{ template "mastodon.pvc.system" . }} {{- end }} containers: - name: {{ include "mastodon.fullname" . }}-chewy-setup diff --git a/templates/job-create-admin.yaml b/templates/job-create-admin.yaml index 3d137f5..f38518f 100644 --- a/templates/job-create-admin.yaml +++ b/templates/job-create-admin.yaml @@ -37,10 +37,10 @@ spec: volumes: - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-assets + claimName: {{ template "mastodon.pvc.assets" . }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-system + claimName: {{ template "mastodon.pvc.system" . }} {{- end }} containers: - name: {{ include "mastodon.fullname" . }}-create-admin diff --git a/templates/job-db-migrate.yaml b/templates/job-db-migrate.yaml index e9a40a7..d680c49 100644 --- a/templates/job-db-migrate.yaml +++ b/templates/job-db-migrate.yaml @@ -37,10 +37,10 @@ spec: volumes: - name: assets persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-assets + claimName: {{ template "mastodon.pvc.assets" . }} - name: system persistentVolumeClaim: - claimName: {{ template "mastodon.fullname" . }}-system + claimName: {{ template "mastodon.pvc.system" . }} {{- end }} containers: - name: {{ include "mastodon.fullname" . }}-db-migrate diff --git a/templates/pvc-assets.yaml b/templates/pvc-assets.yaml index 46c90ca..4f902f6 100644 --- a/templates/pvc-assets.yaml +++ b/templates/pvc-assets.yaml @@ -1,4 +1,4 @@ -{{- if (not .Values.mastodon.s3.enabled) -}} +{{- if and (not .Values.mastodon.s3.enabled) (not .Values.mastodon.persistence.assets.existingClaim) -}} apiVersion: v1 kind: PersistentVolumeClaim metadata: diff --git a/templates/pvc-system.yaml b/templates/pvc-system.yaml index 9865346..b67d63e 100644 --- a/templates/pvc-system.yaml +++ b/templates/pvc-system.yaml @@ -1,4 +1,4 @@ -{{- if (not .Values.mastodon.s3.enabled) -}} +{{- if and (not .Values.mastodon.s3.enabled) (not .Values.mastodon.persistence.system.existingClaim) -}} apiVersion: v1 kind: PersistentVolumeClaim metadata: diff --git a/values.yaml b/values.yaml index 9d8d2ba..bd340b7 100644 --- a/values.yaml +++ b/values.yaml @@ -62,11 +62,15 @@ mastodon: resources: requests: storage: 10Gi + # -- name of existing persistent volume claim to use for assets + existingClaim: system: accessMode: ReadWriteOnce resources: requests: storage: 100Gi + # -- name of existing persistent volume claim to use for system + existingClaim: s3: enabled: false access_key: ""