From 7e08a5f5918a42eee04e6d0b8c3d42cddaf0b040 Mon Sep 17 00:00:00 2001 From: kjeld Schouten-Lebbing Date: Mon, 8 Nov 2021 17:37:56 +0100 Subject: [PATCH] feat(postgresql): also set and remember postgresql root password --- charts/dependency/postgresql/Chart.yaml | 2 +- charts/dependency/postgresql/values.yaml | 5 +++++ charts/library/common/Chart.yaml | 2 +- .../common/templates/lib/dependencies/_postgresInjector.tpl | 6 +++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/charts/dependency/postgresql/Chart.yaml b/charts/dependency/postgresql/Chart.yaml index 603cb099e16..881afc333c4 100644 --- a/charts/dependency/postgresql/Chart.yaml +++ b/charts/dependency/postgresql/Chart.yaml @@ -22,7 +22,7 @@ name: postgresql sources: - https://www.postgresql.org/ type: application -version: 5.1.13 +version: 5.1.14 annotations: truecharts.org/catagories: | - database diff --git a/charts/dependency/postgresql/values.yaml b/charts/dependency/postgresql/values.yaml index afcef2786ec..5f80cf4a59b 100644 --- a/charts/dependency/postgresql/values.yaml +++ b/charts/dependency/postgresql/values.yaml @@ -32,6 +32,7 @@ persistence: postgresqlPassword: "testpass" postgresqlUsername: "test" postgresqlDatabase: "test" +postgrespassword: "testroot" existingSecret: "" envValueFrom: @@ -39,6 +40,10 @@ envValueFrom: secretKeyRef: name: '{{ ( tpl .Values.existingSecret $ ) | default ( include "common.names.fullname" . ) }}' key: "postgresql-password" + POSTGRESQL_POSTGRES_PASSWORD: + secretKeyRef: + name: '{{ ( tpl .Values.existingSecret $ ) | default ( include "common.names.fullname" . ) }}' + key: "postgresql-postgres-password" envTpl: POSTGRES_USER: "{{ .Values.postgresqlUsername }}" diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 9e919a94e40..54204308456 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 8.5.3 +version: 8.5.4 diff --git a/charts/library/common/templates/lib/dependencies/_postgresInjector.tpl b/charts/library/common/templates/lib/dependencies/_postgresInjector.tpl index 3781a88c237..9c308f7a028 100644 --- a/charts/library/common/templates/lib/dependencies/_postgresInjector.tpl +++ b/charts/library/common/templates/lib/dependencies/_postgresInjector.tpl @@ -14,15 +14,18 @@ metadata: name: dbcreds {{- $dbprevious := lookup "v1" "Secret" .Release.Namespace "dbcreds" }} {{- $dbPass := "" }} +{{- $pgPass := "" }} data: {{- if $dbprevious }} {{- $dbPass = ( index $dbprevious.data "postgresql-password" ) | b64dec }} + {{- $pgPass = ( index $dbprevious.data "postgresql-postgres-password" ) | b64dec }} postgresql-password: {{ ( index $dbprevious.data "postgresql-password" ) }} postgresql-postgres-password: {{ ( index $dbprevious.data "postgresql-postgres-password" ) }} {{- else }} {{- $dbPass = randAlphaNum 50 }} + {{- $pgPass = randAlphaNum 50 }} postgresql-password: {{ $dbPass | b64enc | quote }} - postgresql-postgres-password: {{ randAlphaNum 50 | b64enc | quote }} + postgresql-postgres-password: {{ $pgPass | b64enc | quote }} {{- end }} url: {{ ( printf "postgresql://%v:%v@%v-postgresql:5432/%v" .Values.postgresql.postgresqlUsername $dbPass .Release.Name .Values.postgresql.postgresqlDatabase ) | b64enc | quote }} urlnossl: {{ ( printf "postgresql://%v:%v@%v-postgresql:5432/%v?sslmode=disable" .Values.postgresql.postgresqlUsername $dbPass .Release.Name .Values.postgresql.postgresqlDatabase ) | b64enc | quote }} @@ -31,6 +34,7 @@ data: jdbc: {{ ( printf "jdbc:postgresql://%v-postgresql:5432/%v" .Release.Name .Values.postgresql.postgresqlDatabase ) | b64enc | quote }} type: Opaque {{- $_ := set .Values.postgresql "postgresqlPassword" ( $dbPass | quote ) }} +{{- $_ := set .Values.postgresql "postgrespassword" ( $pgPass | quote ) }} {{- $_ := set .Values.postgresql.url "plain" ( ( printf "%v-%v" .Release.Name "postgresql" ) | quote ) }} {{- $_ := set .Values.postgresql.url "plainhost" ( ( printf "%v-%v" .Release.Name "postgresql" ) | quote ) }} {{- $_ := set .Values.postgresql.url "plainport" ( ( printf "%v-%v:5432" .Release.Name "postgresql" ) | quote ) }}