From 98801d7c09880d4d80e81c8753420db418f2be27 Mon Sep 17 00:00:00 2001 From: Tim Campbell Date: Tue, 4 Mar 2025 17:47:01 +0100 Subject: [PATCH 1/3] Fix asset upload (#167) --- templates/job-assets-copy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/job-assets-copy.yaml b/templates/job-assets-copy.yaml index d35a7bc..2ac51fa 100644 --- a/templates/job-assets-copy.yaml +++ b/templates/job-assets-copy.yaml @@ -7,7 +7,7 @@ metadata: {{- include "mastodon.labels" . | nindent 4 }} annotations: "helm.sh/hook": pre-install,pre-upgrade - "helm.sh/hook-delete-policy": before-hook-creation + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded "helm.sh/hook-weight": "-1" spec: template: From ac8cd229d8ada9fd57b2eb51ba94f32291365bd3 Mon Sep 17 00:00:00 2001 From: Tim Campbell Date: Tue, 4 Mar 2025 18:01:51 +0100 Subject: [PATCH 2/3] Added additional DB connection fields to deal with connection pooler migrations (#169) --- templates/_db-migrate.tpl | 6 +++--- templates/_helpers.tpl | 27 +++++++++++++++++++++++++++ values.yaml | 10 ++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/templates/_db-migrate.tpl b/templates/_db-migrate.tpl index 042faf3..c3792c7 100644 --- a/templates/_db-migrate.tpl +++ b/templates/_db-migrate.tpl @@ -57,11 +57,11 @@ spec: {{- end }} env: - name: "DB_HOST" - value: {{ template "mastodon.postgres.host" . }} + value: {{ template "mastodon.postgres.direct.host" . }} - name: "DB_PORT" - value: {{ template "mastodon.postgres.port" . }} + value: {{ template "mastodon.postgres.direct.port" . }} - name: "DB_NAME" - value: {{ .Values.postgresql.auth.database }} + value: {{ template "mastodon.postgres.direct.database" . }} - name: "DB_USER" value: {{ .Values.postgresql.auth.username }} - name: "DB_PASS" diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 91409e0..b34ff95 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -140,6 +140,33 @@ Establish which values we will use for remote connections {{- end }} {{- end }} +{{/* +Establish which values we will use for direct remote DB connections +*/}} +{{- define "mastodon.postgres.direct.host" -}} +{{- if .Values.postgresql.direct.hostname }} +{{- printf "%s" .Values.postgresql.direct.hostname -}} +{{- else }} +{{- printf "%s" (include "mastodon.postgres.host" .) -}} +{{- end }} +{{- end }} + +{{- define "mastodon.postgres.direct.port" -}} +{{- if .Values.postgresql.direct.port }} +{{- printf "%d" (int .Values.postgresql.direct.port) | quote -}} +{{- else }} +{{- printf "%s" (include "mastodon.postgres.port" .) -}} +{{- end }} +{{- end }} + +{{- define "mastodon.postgres.direct.database" -}} +{{- if .Values.postgresql.direct.database }} +{{- printf "%s" .Values.postgresql.direct.database -}} +{{- else }} +{{- printf "%s" .Values.postgresql.auth.database -}} +{{- end }} +{{- end }} + {{- define "mastodon.redis.host" -}} {{- if .Values.redis.enabled }} {{- printf "%s-%s" (include "mastodon.redis.fullname" .) "master" -}} diff --git a/values.yaml b/values.yaml index 7ad93af..5b1ec64 100644 --- a/values.yaml +++ b/values.yaml @@ -532,6 +532,16 @@ postgresql: enabled: true # postgresqlHostname: preexisting-postgresql # postgresqlPort: 5432 + + # If using a connection pooler such as pgbouncer, please specify a hostname/IP + # that serves as a "direct" connection to the database, rather than going + # through the connection pooler. This is required for migrations to work + # properly. + direct: + hostname: + port: + database: + auth: database: mastodon_production username: mastodon From 8ea5eadf9985837652c18d11a0f4f19ce9f4e0ca Mon Sep 17 00:00:00 2001 From: Tim Campbell Date: Tue, 4 Mar 2025 22:33:26 +0100 Subject: [PATCH 3/3] Fix some helm typos (comments interfering with manifests) (#172) --- templates/job-db-prepare.yaml | 1 - templates/secret-prepare.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/templates/job-db-prepare.yaml b/templates/job-db-prepare.yaml index 5f0b5ab..5e9a6a2 100644 --- a/templates/job-db-prepare.yaml +++ b/templates/job-db-prepare.yaml @@ -1,4 +1,3 @@ -# Does not work with included database because of helm install order. {{- if not .Values.postgresql.enabled }} {{- include "mastodon.dbMigrateJob" (merge (dict "prepare" true ) .) }} {{- end }} diff --git a/templates/secret-prepare.yml b/templates/secret-prepare.yml index 8cfac53..375f047 100644 --- a/templates/secret-prepare.yml +++ b/templates/secret-prepare.yml @@ -1,4 +1,3 @@ -# Does not work with included database because of helm install order. {{- if and (include "mastodon.createSecret" .) (not .Values.postgresql.enabled) -}} {{- include "mastodon.secrets.object" (merge (dict "prepare" true ) .) }} {{- end }}