From eee839e548639319b9864bce001ddec184cbb3ca Mon Sep 17 00:00:00 2001 From: Jonathan Bartlett <34320158+Jonnobrow@users.noreply.github.com> Date: Mon, 10 Jan 2022 23:32:07 +0000 Subject: [PATCH] [dendrite] Fix postgresql init scripts for dendrite (#1368) * fix(dendrite/postgresql): fix init scripts Init scripts for postgresql not are generated dynamically so the correct username is used. Additionally they are loaded from a configmap rather than injected into the values which did not work. Also refactored into separated file for easier maintenance. * docs(dendrite): Bump version and update changelog annotations * docs(dendrite): Generate README --- charts/incubator/dendrite/Chart.yaml | 8 ++++++-- charts/incubator/dendrite/README.md | 13 ++++++++----- charts/incubator/dendrite/templates/common.yaml | 8 -------- .../dendrite/templates/postgresql-initdb.yaml | 14 ++++++++++++++ charts/incubator/dendrite/values.yaml | 4 ++++ 5 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 charts/incubator/dendrite/templates/postgresql-initdb.yaml diff --git a/charts/incubator/dendrite/Chart.yaml b/charts/incubator/dendrite/Chart.yaml index ebb93ab9..58753370 100644 --- a/charts/incubator/dendrite/Chart.yaml +++ b/charts/incubator/dendrite/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 appVersion: 0.5.1 description: Dendrite Matrix Homeserver name: dendrite -version: 1.0.1 +version: 1.0.2 kubeVersion: ">=1.16.0-0" keywords: - dendrite @@ -29,4 +29,8 @@ dependencies: annotations: artifacthub.io/changes: | - kind: changed - description: Upgraded `postgresql` chart dependency to version `10.14.4`. + description: Upgraded `postgresql` image version to "14.1.0" + - kind: fixed + description: "`initdbScripts` are now actually actually loaded" + - kind: added + description: "`postgresqlUsername` is used in `initdbScripts` rather than hardcoded value" diff --git a/charts/incubator/dendrite/README.md b/charts/incubator/dendrite/README.md index 1e3fbd0d..29f18194 100644 --- a/charts/incubator/dendrite/README.md +++ b/charts/incubator/dendrite/README.md @@ -1,6 +1,6 @@ # dendrite -![Version: 1.0.1](https://img.shields.io/badge/Version-1.0.1-informational?style=flat-square) ![AppVersion: 0.5.1](https://img.shields.io/badge/AppVersion-0.5.1-informational?style=flat-square) +![Version: 1.0.2](https://img.shields.io/badge/Version-1.0.2-informational?style=flat-square) ![AppVersion: 0.5.1](https://img.shields.io/badge/AppVersion-0.5.1-informational?style=flat-square) Dendrite Matrix Homeserver @@ -109,6 +109,9 @@ N/A | ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | | persistence | object | See values.yaml | Configure persistence settings for the chart under this key. | | postgresql.enabled | bool | See value.yaml | Enable and configure postgres as the database for dendrite. | +| postgresql.image.repository | string | `"bitnami/postgresql"` | | +| postgresql.image.tag | string | `"14.1.0"` | | +| postgresql.initdbScriptsConfigMap | string | `"dendrite-postgresql-init-scripts"` | | | postgresql.persistence.enabled | bool | `false` | | | postgresql.postgresqlDatabase | string | `"dendrite"` | | | postgresql.postgresqlPassword | string | `"changeme"` | | @@ -119,19 +122,19 @@ N/A ## Changelog -### Version 1.0.1 +### Version 1.0.2 #### Added -N/A +* `postgresqlUsername` is used in `initdbScripts` rather than hardcoded value #### Changed -* Upgraded `postgresql` chart dependency to version `10.14.4`. +* Upgraded `postgresql` image version to "14.1.0" #### Fixed -N/A +* `initdbScripts` are now actually actually loaded ### Older versions diff --git a/charts/incubator/dendrite/templates/common.yaml b/charts/incubator/dendrite/templates/common.yaml index 459f7ada..e0d4637b 100644 --- a/charts/incubator/dendrite/templates/common.yaml +++ b/charts/incubator/dendrite/templates/common.yaml @@ -38,13 +38,5 @@ subPath: {{- $_ := set .Values.persistence "dendrite-key" (include "dendrite.keyVolume" . | fromYaml) -}} {{- $_ := set .Values.persistence "dendrite-config" (include "dendrite.configVolume" . | fromYaml) -}} {{- $_ := set .Values.persistence "dendrite-tls" (include "dendrite.tlsVolume" . | fromYaml) -}} -{{- define "postgresql.initdbScripts" -}} -create_db.sh: | - #!/bin/sh - for db in userapi_accounts userapi_devices mediaapi syncapi roomserver keyserver federationapi appservice naffka; do - createdb -U dendrite -O dendrite dendrite_$db - done -{{- end -}} -{{- $_ := set .Values.postgresql "initdbScripts" (include "postgresql.initdbScripts" . | fromYaml) -}} {{ include "common.all" . }} diff --git a/charts/incubator/dendrite/templates/postgresql-initdb.yaml b/charts/incubator/dendrite/templates/postgresql-initdb.yaml new file mode 100644 index 00000000..666480d5 --- /dev/null +++ b/charts/incubator/dendrite/templates/postgresql-initdb.yaml @@ -0,0 +1,14 @@ +{{- if .Values.postgresql.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + creationTimestamp: null + name: {{ .Values.postgresql.initdbScriptsConfigMap | quote }} +data: + create-db.sh: | + #!/bin/sh + for db in userapi_accounts userapi_devices mediaapi syncapi roomserver keyserver federationapi appservice naffka; do + createdb -U {{ .Values.postgresql.postgresqlUsername }} -O {{ .Values.postgresql.postgresqlUsername }} dendrite_$db + done +{{- end }} diff --git a/charts/incubator/dendrite/values.yaml b/charts/incubator/dendrite/values.yaml index 9b3e9a38..d44a477e 100644 --- a/charts/incubator/dendrite/values.yaml +++ b/charts/incubator/dendrite/values.yaml @@ -201,8 +201,12 @@ postgresql: # -- Enable and configure postgres as the database for dendrite. # @default -- See value.yaml enabled: false + image: + repository: bitnami/postgresql + tag: "14.1.0" postgresqlUsername: dendrite postgresqlPassword: changeme postgresqlDatabase: dendrite persistence: enabled: false + initdbScriptsConfigMap: "dendrite-postgresql-init-scripts"