From 0e729406c3365cb12bcaa777fa713d6f85616851 Mon Sep 17 00:00:00 2001 From: jessebot Date: Fri, 14 Jul 2023 15:34:00 +0200 Subject: [PATCH] allow for an existingClaim for both assets and system --- charts/mastodon/Chart.yaml | 2 +- charts/mastodon/README.md | 4 +++- charts/mastodon/templates/_helpers.tpl | 22 +++++++++++++++++++ .../templates/cronjob-media-remove.yaml | 4 ++-- .../templates/deployment-sidekiq.yaml | 4 ++-- charts/mastodon/templates/deployment-web.yaml | 4 ++-- .../templates/job-assets-precompile.yaml | 10 ++++----- .../mastodon/templates/job-chewy-upgrade.yaml | 4 ++-- .../mastodon/templates/job-create-admin.yaml | 4 ++-- charts/mastodon/templates/job-db-migrate.yaml | 4 ++-- charts/mastodon/templates/pvc-assets.yaml | 2 +- charts/mastodon/templates/pvc-system.yaml | 2 +- charts/mastodon/values.yaml | 4 ++++ 13 files changed, 49 insertions(+), 21 deletions(-) diff --git a/charts/mastodon/Chart.yaml b/charts/mastodon/Chart.yaml index 267399a..87b29a2 100644 --- a/charts/mastodon/Chart.yaml +++ b/charts/mastodon/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 4.0.9 +version: 4.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/mastodon/README.md b/charts/mastodon/README.md index 51e9358..77bf4e1 100644 --- a/charts/mastodon/README.md +++ b/charts/mastodon/README.md @@ -1,6 +1,6 @@ # mastodon -![Version: 4.0.9](https://img.shields.io/badge/Version-4.0.9-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v4.1.4](https://img.shields.io/badge/AppVersion-v4.1.4-informational?style=flat-square) +![Version: 4.1.0](https://img.shields.io/badge/Version-4.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v4.1.4](https://img.shields.io/badge/AppVersion-v4.1.4-informational?style=flat-square) Mastodon is a free, open-source social network server based on ActivityPub. @@ -45,8 +45,10 @@ Mastodon is a free, open-source social network server based on ActivityPub. | mastodon.locale | string | `"en"` | available locales: https://github.com/mastodon/mastodon/blob/main/config/application.rb#L71 | | mastodon.metrics.statsd.address | string | `""` | Enable statsd publishing via STATSD_ADDR environment variable | | mastodon.persistence.assets.accessMode | string | `"ReadWriteOnce"` | ReadWriteOnce is more widely supported than ReadWriteMany, but limits scalability, since it requires the Rails and Sidekiq pods to run on the same node. | +| mastodon.persistence.assets.existingClaim | string | `nil` | name of existing persistent volume claim to use for assets | | mastodon.persistence.assets.resources.requests.storage | string | `"10Gi"` | | | mastodon.persistence.system.accessMode | string | `"ReadWriteOnce"` | | +| mastodon.persistence.system.existingClaim | string | `nil` | name of existing persistent volume claim to use for system | | mastodon.persistence.system.resources.requests.storage | string | `"100Gi"` | | | mastodon.preparedStatements | bool | `true` | | | mastodon.s3.access_key | string | `""` | | diff --git a/charts/mastodon/templates/_helpers.tpl b/charts/mastodon/templates/_helpers.tpl index 6c0940a..974adff 100644 --- a/charts/mastodon/templates/_helpers.tpl +++ b/charts/mastodon/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/charts/mastodon/templates/cronjob-media-remove.yaml b/charts/mastodon/templates/cronjob-media-remove.yaml index e8545ca..ed99d29 100644 --- a/charts/mastodon/templates/cronjob-media-remove.yaml +++ b/charts/mastodon/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/charts/mastodon/templates/deployment-sidekiq.yaml b/charts/mastodon/templates/deployment-sidekiq.yaml index adcbb50..d1670d5 100644 --- a/charts/mastodon/templates/deployment-sidekiq.yaml +++ b/charts/mastodon/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/charts/mastodon/templates/deployment-web.yaml b/charts/mastodon/templates/deployment-web.yaml index d04db8f..cc8438d 100644 --- a/charts/mastodon/templates/deployment-web.yaml +++ b/charts/mastodon/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/charts/mastodon/templates/job-assets-precompile.yaml b/charts/mastodon/templates/job-assets-precompile.yaml index bc5ff7b..f350000 100644 --- a/charts/mastodon/templates/job-assets-precompile.yaml +++ b/charts/mastodon/templates/job-assets-precompile.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ include "mastodon.fullname" . }}-assets-precompile + name: {{ include "mastodon.pvc.assets" . }}-precompile labels: {{- include "mastodon.labels" . | nindent 4 }} annotations: @@ -11,7 +11,7 @@ metadata: spec: template: metadata: - name: {{ include "mastodon.fullname" . }}-assets-precompile + name: {{ include "mastodon.pvc.assets" . }}-precompile {{- with .Values.jobAnnotations }} annotations: {{- toYaml . | nindent 8 }} @@ -36,13 +36,13 @@ 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 + - name: {{ include "mastodon.pvc.assets" . }}-precompile image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} command: diff --git a/charts/mastodon/templates/job-chewy-upgrade.yaml b/charts/mastodon/templates/job-chewy-upgrade.yaml index f86a4e3..7340115 100644 --- a/charts/mastodon/templates/job-chewy-upgrade.yaml +++ b/charts/mastodon/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/charts/mastodon/templates/job-create-admin.yaml b/charts/mastodon/templates/job-create-admin.yaml index 12d0e1c..5d9f062 100644 --- a/charts/mastodon/templates/job-create-admin.yaml +++ b/charts/mastodon/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/charts/mastodon/templates/job-db-migrate.yaml b/charts/mastodon/templates/job-db-migrate.yaml index 8ea3a7e..211b762 100644 --- a/charts/mastodon/templates/job-db-migrate.yaml +++ b/charts/mastodon/templates/job-db-migrate.yaml @@ -35,10 +35,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/charts/mastodon/templates/pvc-assets.yaml b/charts/mastodon/templates/pvc-assets.yaml index 36d5558..51e5f3d 100644 --- a/charts/mastodon/templates/pvc-assets.yaml +++ b/charts/mastodon/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/charts/mastodon/templates/pvc-system.yaml b/charts/mastodon/templates/pvc-system.yaml index 9865346..b67d63e 100644 --- a/charts/mastodon/templates/pvc-system.yaml +++ b/charts/mastodon/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/charts/mastodon/values.yaml b/charts/mastodon/values.yaml index fcb47ea..788e351 100644 --- a/charts/mastodon/values.yaml +++ b/charts/mastodon/values.yaml @@ -54,11 +54,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: ""