From 3e9ae3e9f22297c1fe7ba89133c14ae53019c7d7 Mon Sep 17 00:00:00 2001 From: Tim Campbell Date: Tue, 14 May 2024 21:40:45 +0200 Subject: [PATCH] Additional configuration for redis instances --- templates/_helpers.tpl | 30 ++++++++++++++++++++++++++++ templates/configmap-env.yaml | 25 ++++++++++++++++++++++- templates/cronjob-media-remove.yaml | 14 +++++++++++++ templates/deployment-sidekiq.yaml | 14 +++++++++++++ templates/deployment-streaming.yaml | 14 +++++++++++++ templates/deployment-web.yaml | 14 +++++++++++++ templates/job-assets-precompile.yaml | 14 +++++++++++++ templates/job-chewy-upgrade.yaml | 14 +++++++++++++ templates/job-create-admin.yaml | 14 +++++++++++++ templates/job-db-migrate.yaml | 14 +++++++++++++ 10 files changed, 166 insertions(+), 1 deletion(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 81872f9..1347a67 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -147,6 +147,36 @@ Get the redis secret. {{- end -}} {{- end -}} +{{/* +Get the redis secret (sidekiq). +*/}} +{{- define "mastodon.redis.sidekiq.secretName" -}} +{{- if .Values.redis.sidekiq.auth.existingSecret }} + {{- printf "%s" (tpl .Values.redis.sidekiq.auth.existingSecret $) -}} +{{- else if .Values.redis.auth.existingSecret }} + {{- printf "%s" (tpl .Values.redis.auth.existingSecret $) -}} +{{- else if .Values.redis.existingSecret }} + {{- printf "%s" (tpl .Values.redis.existingSecret $) -}} +{{- else -}} + {{- printf "%s-redis" (tpl .Release.Name $) -}} +{{- end -}} +{{- end -}} + +{{/* +Get the redis secret (cache). +*/}} +{{- define "mastodon.redis.cache.secretName" -}} +{{- if .Values.redis.cache.auth.existingSecret }} + {{- printf "%s" (tpl .Values.redis.cache.auth.existingSecret $) -}} +{{- else if .Values.redis.auth.existingSecret }} + {{- printf "%s" (tpl .Values.redis.auth.existingSecret $) -}} +{{- else if .Values.redis.existingSecret }} + {{- printf "%s" (tpl .Values.redis.existingSecret $) -}} +{{- else -}} + {{- printf "%s-redis" (tpl .Release.Name $) -}} +{{- end -}} +{{- end -}} + {{/* Return true if a mastodon secret object should be created */}} diff --git a/templates/configmap-env.yaml b/templates/configmap-env.yaml index b36b7dc..7db39f9 100644 --- a/templates/configmap-env.yaml +++ b/templates/configmap-env.yaml @@ -72,6 +72,30 @@ data: REDIS_HOST: {{ required "When the redis chart is disabled .Values.redis.hostname is required" .Values.redis.hostname }} {{- end }} REDIS_PORT: {{ .Values.redis.port | default "6379" | quote }} + {{- if .Values.redis.sidekiq.enabled }} + {{- if .Values.redis.sidekiq.host }} + SIDEKIQ_REDIS_HOST: {{ .Values.redis.sidekiq.host }} + {{- else }} + SIDEKIQ_REDIS_HOST: {{ .Values.redis.host }} + {{- end }} + {{- if .Values.redis.sidekiq.port }} + SIDEKIQ_REDIS_PORT: {{ .Values.redis.sidekiq.port }} + {{- else }} + SIDEKIQ_REDIS_PORT: {{ .Values.redis.port }} + {{- end }} + {{- end }} + {{- if .Values.redis.cache.enabled }} + {{- if .Values.redis.cache.host }} + CACHE_REDIS_HOST: {{ .Values.redis.cache.host }} + {{- else }} + CACHE_REDIS_HOST: {{ .Values.redis.host}} + {{- end }} + {{- if .Values.redis.cache.port }} + CACHE_REDIS_PORT: {{ .Values.redis.cache.port }} + {{- else }} + CACHE_REDIS_PORT: {{ .Values.redis.port }} + {{- end }} + {{- end }} {{- if .Values.mastodon.s3.enabled }} S3_BUCKET: {{ .Values.mastodon.s3.bucket }} S3_ENABLED: "true" @@ -389,4 +413,3 @@ data: {{- with .Values.timezone }} TZ: {{ . | quote }} {{- end }} - \ No newline at end of file diff --git a/templates/cronjob-media-remove.yaml b/templates/cronjob-media-remove.yaml index 33229a8..3479e90 100644 --- a/templates/cronjob-media-remove.yaml +++ b/templates/cronjob-media-remove.yaml @@ -65,6 +65,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} {{- if and .Values.elasticsearch.existingSecret (or .Values.elasticsearch.enabled .Values.elasticsearch.hostname) }} - name: "ES_PASS" valueFrom: diff --git a/templates/deployment-sidekiq.yaml b/templates/deployment-sidekiq.yaml index f6e9c7e..6a56286 100644 --- a/templates/deployment-sidekiq.yaml +++ b/templates/deployment-sidekiq.yaml @@ -124,6 +124,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" $context }} key: redis-password + {{- if and $context.Values.redis.sidekiq.enabled $context.Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and $context.Values.redis.cache.enabled $context.Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} {{- if and $context.Values.elasticsearch.existingSecret (or $context.Values.elasticsearch.enabled $context.Values.elasticsearch.hostname) }} - name: "ES_PASS" valueFrom: diff --git a/templates/deployment-streaming.yaml b/templates/deployment-streaming.yaml index 8d66361..77705a4 100644 --- a/templates/deployment-streaming.yaml +++ b/templates/deployment-streaming.yaml @@ -103,6 +103,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} - name: "PORT" value: {{ .Values.mastodon.streaming.port | quote }} ports: diff --git a/templates/deployment-web.yaml b/templates/deployment-web.yaml index b1bb0b8..8e70b2d 100644 --- a/templates/deployment-web.yaml +++ b/templates/deployment-web.yaml @@ -101,6 +101,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} {{- if and .Values.elasticsearch.existingSecret (or .Values.elasticsearch.enabled .Values.elasticsearch.hostname) }} - name: "ES_PASS" valueFrom: diff --git a/templates/job-assets-precompile.yaml b/templates/job-assets-precompile.yaml index 3458fea..5632357 100644 --- a/templates/job-assets-precompile.yaml +++ b/templates/job-assets-precompile.yaml @@ -67,6 +67,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} - name: "PORT" value: {{ .Values.mastodon.web.port | quote }} {{- if (not .Values.mastodon.s3.enabled) }} diff --git a/templates/job-chewy-upgrade.yaml b/templates/job-chewy-upgrade.yaml index 33e9bf9..299334e 100644 --- a/templates/job-chewy-upgrade.yaml +++ b/templates/job-chewy-upgrade.yaml @@ -67,6 +67,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} {{- if and .Values.elasticsearch.existingSecret (or .Values.elasticsearch.enabled .Values.elasticsearch.hostname) }} - name: "ES_PASS" valueFrom: diff --git a/templates/job-create-admin.yaml b/templates/job-create-admin.yaml index 3d137f5..7feeeb2 100644 --- a/templates/job-create-admin.yaml +++ b/templates/job-create-admin.yaml @@ -72,6 +72,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} - name: "PORT" value: {{ .Values.mastodon.web.port | quote }} {{- if (not .Values.mastodon.s3.enabled) }} diff --git a/templates/job-db-migrate.yaml b/templates/job-db-migrate.yaml index e9a40a7..a71e364 100644 --- a/templates/job-db-migrate.yaml +++ b/templates/job-db-migrate.yaml @@ -67,6 +67,20 @@ spec: secretKeyRef: name: {{ template "mastodon.redis.secretName" . }} key: redis-password + {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.sidekiq.secretName" . }} + key: redis-password + {{- end }} + {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }} + - name: "SIDEKIQ_REDIS_PASSWORD" + valueFrom: + secretKeyRef: + name: {{ template "mastodon.redis.cache.secretName" . }} + key: redis-password + {{- end }} - name: "PORT" value: {{ .Values.mastodon.web.port | quote }} {{- if (not .Values.mastodon.s3.enabled) }}