about summary refs log tree commit diff
path: root/chart
diff options
context:
space:
mode:
authorAlex Dunn <dunn.alex@gmail.com>2021-02-14 11:16:32 -0800
committerGitHub <noreply@github.com>2021-02-14 20:16:32 +0100
commit55a6b54f8ee6b04845f1a4a8507ba9907670a739 (patch)
tree3ba3b739901f9b779af504cd594e8712c4e7d293 /chart
parent3447bd2f80111ce7373446182055c819a01c03b6 (diff)
helm: add option for external db (#15722)
Diffstat (limited to 'chart')
-rw-r--r--chart/Chart.yaml1
-rw-r--r--chart/templates/configmap-env.yaml4
-rw-r--r--chart/templates/cronjob-media-remove.yaml2
-rw-r--r--chart/templates/deployment-sidekiq.yaml4
-rw-r--r--chart/templates/deployment-streaming.yaml4
-rw-r--r--chart/templates/deployment-web.yaml4
-rw-r--r--chart/templates/job-assets-precompile.yaml4
-rw-r--r--chart/templates/job-chewy-upgrade.yaml4
-rw-r--r--chart/templates/job-create-admin.yaml4
-rw-r--r--chart/templates/job-db-migrate.yaml4
-rw-r--r--chart/templates/secrets.yaml3
-rw-r--r--chart/values.yaml.template4
12 files changed, 41 insertions, 1 deletions
diff --git a/chart/Chart.yaml b/chart/Chart.yaml
index 19f9c64c7..a1db340e6 100644
--- a/chart/Chart.yaml
+++ b/chart/Chart.yaml
@@ -30,6 +30,7 @@ dependencies:
   - name: postgresql
     version: "8.x.x"
     repository: https://charts.bitnami.com/bitnami
+    condition: postgresql.enabled
   - name: redis
     version: "10.x.x"
     repository: https://charts.bitnami.com/bitnami
diff --git a/chart/templates/configmap-env.yaml b/chart/templates/configmap-env.yaml
index 27351e97e..2f93a4b3c 100644
--- a/chart/templates/configmap-env.yaml
+++ b/chart/templates/configmap-env.yaml
@@ -5,7 +5,11 @@ metadata:
   labels:
     {{- include "mastodon.labels" . | nindent 4 }}
 data:
+  {{- if .Values.postgresql.enabled }}
   DB_HOST: {{ template "mastodon.postgresql.fullname" . }}
+  {{- else }}
+  DB_HOST: {{ .Values.postgresql.postgresqlHostname }}
+  {{- end }}
   DB_NAME: {{ .Values.postgresql.postgresqlDatabase }}
   DB_POOL: {{ .Values.application.sidekiq.concurrency | quote }}
   DB_PORT: "5432"
diff --git a/chart/templates/cronjob-media-remove.yaml b/chart/templates/cronjob-media-remove.yaml
index 8a01a2551..5d78f3395 100644
--- a/chart/templates/cronjob-media-remove.yaml
+++ b/chart/templates/cronjob-media-remove.yaml
@@ -55,7 +55,7 @@ spec:
                       {{- if .Values.postgresql.enabled }}
                       name: {{ .Release.Name }}-postgresql
                       {{- else }}
-                      name: {{ template "mastodon.fullname" . }}-postgresql
+                      name: {{ template "mastodon.fullname" . }}
                       {{- end }}
                       key: postgresql-password
                 - name: "REDIS_PASSWORD"
diff --git a/chart/templates/deployment-sidekiq.yaml b/chart/templates/deployment-sidekiq.yaml
index 5457183a3..f300a5e63 100644
--- a/chart/templates/deployment-sidekiq.yaml
+++ b/chart/templates/deployment-sidekiq.yaml
@@ -73,7 +73,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/deployment-streaming.yaml b/chart/templates/deployment-streaming.yaml
index 5d642d72c..02efcc3dc 100644
--- a/chart/templates/deployment-streaming.yaml
+++ b/chart/templates/deployment-streaming.yaml
@@ -43,7 +43,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/deployment-web.yaml b/chart/templates/deployment-web.yaml
index 5010e567a..a531aa487 100644
--- a/chart/templates/deployment-web.yaml
+++ b/chart/templates/deployment-web.yaml
@@ -59,7 +59,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/job-assets-precompile.yaml b/chart/templates/job-assets-precompile.yaml
index 5472e06d6..32e5c71d3 100644
--- a/chart/templates/job-assets-precompile.yaml
+++ b/chart/templates/job-assets-precompile.yaml
@@ -53,7 +53,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/job-chewy-upgrade.yaml b/chart/templates/job-chewy-upgrade.yaml
index 789fcff83..4d645168a 100644
--- a/chart/templates/job-chewy-upgrade.yaml
+++ b/chart/templates/job-chewy-upgrade.yaml
@@ -54,7 +54,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/job-create-admin.yaml b/chart/templates/job-create-admin.yaml
index 3c5bdd6eb..aabb593ac 100644
--- a/chart/templates/job-create-admin.yaml
+++ b/chart/templates/job-create-admin.yaml
@@ -59,7 +59,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/job-db-migrate.yaml b/chart/templates/job-db-migrate.yaml
index e07832386..dd687a066 100644
--- a/chart/templates/job-db-migrate.yaml
+++ b/chart/templates/job-db-migrate.yaml
@@ -53,7 +53,11 @@ spec:
             - name: "DB_PASS"
               valueFrom:
                 secretKeyRef:
+                  {{- if .Values.postgresql.enabled }}
                   name: {{ .Release.Name }}-postgresql
+                  {{- else }}
+                  name: {{ template "mastodon.fullname" . }}
+                  {{- end }}
                   key: postgresql-password
             - name: "REDIS_PASSWORD"
               valueFrom:
diff --git a/chart/templates/secrets.yaml b/chart/templates/secrets.yaml
index 74f4b1516..80f24a121 100644
--- a/chart/templates/secrets.yaml
+++ b/chart/templates/secrets.yaml
@@ -26,3 +26,6 @@ data:
   {{- else }}
   VAPID_PUBLIC_KEY: {{ required "vapid.public_key is required" .Values.secrets.vapid.public_key }}
   {{- end }}
+  {{- if not .Values.postgresql.enabled }}
+  postgresql-password: "{{ .Values.postgresql.postgresqlPassword | b64enc }}"
+  {{- end }}
diff --git a/chart/values.yaml.template b/chart/values.yaml.template
index 9e50c6dac..a57621b9e 100644
--- a/chart/values.yaml.template
+++ b/chart/values.yaml.template
@@ -95,6 +95,10 @@ elasticsearch:
 
 # https://github.com/bitnami/charts/tree/master/bitnami/postgresql#parameters
 postgresql:
+  # disable if you want to use an existing db; in which case the values below
+  # must match those of that external postgres instance
+  enabled: true
+  # postgresqlHostname: preexisting-postgresql
   postgresqlDatabase: mastodon_production
   # you must set a password; the password generated by the postgresql chart will
   # be rotated on each upgrade: