From c7098c487f72fce572f3c309f4bf57f2f69da106 Mon Sep 17 00:00:00 2001 From: jessebot Date: Fri, 14 Jul 2023 16:15:25 +0200 Subject: [PATCH] add and --- templates/_helpers.tpl | 22 ++++++++++++++++++++++ templates/cronjob-media-remove.yaml | 4 ++-- templates/deployment-sidekiq.yaml | 4 ++-- templates/deployment-web.yaml | 4 ++-- templates/job-assets-precompile.yaml | 4 ++-- templates/job-chewy-upgrade.yaml | 4 ++-- templates/job-create-admin.yaml | 4 ++-- templates/job-db-migrate.yaml | 4 ++-- templates/pvc-assets.yaml | 2 +- templates/pvc-system.yaml | 2 +- values.yaml | 4 ++++ 11 files changed, 42 insertions(+), 16 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 6331a267..36396432 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -73,6 +73,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 d70afebc..068ef609 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 5dc92441..2150de92 100644 --- a/templates/deployment-sidekiq.yaml +++ b/templates/deployment-sidekiq.yaml @@ -58,10 +58,10 @@ spec: volumes: - 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 }} containers: - name: {{ $context.Chart.Name }} diff --git a/templates/deployment-web.yaml b/templates/deployment-web.yaml index 420c2779..378c74ae 100644 --- a/templates/deployment-web.yaml +++ b/templates/deployment-web.yaml @@ -41,10 +41,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: {{ .Chart.Name }}-web diff --git a/templates/job-assets-precompile.yaml b/templates/job-assets-precompile.yaml index bc5ff7bf..5ca21c45 100644 --- a/templates/job-assets-precompile.yaml +++ b/templates/job-assets-precompile.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" . }}-assets-precompile diff --git a/templates/job-chewy-upgrade.yaml b/templates/job-chewy-upgrade.yaml index f86a4e34..7340115e 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 3d137f5c..f38518f4 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 41324fbd..eb92ae70 100644 --- a/templates/job-db-migrate.yaml +++ b/templates/job-db-migrate.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" . }}-db-migrate diff --git a/templates/pvc-assets.yaml b/templates/pvc-assets.yaml index 36d55589..84e3ec7d 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 9865346e..cd35d9ae 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 a4660e27..0cfb0c7b 100644 --- a/values.yaml +++ b/values.yaml @@ -49,11 +49,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: ""