From b4262dbaaebff265304aca74029af5f92db0d180 Mon Sep 17 00:00:00 2001 From: "Felipe V.C. Serafim" <43246350+fevisera@users.noreply.github.com> Date: Wed, 3 May 2023 10:59:57 +0200 Subject: [PATCH] [bitnami/mariadb] Fix mariadb upgrade (#16265) * Fix mariadb upgrade Signed-off-by: sfelipe * Bump chart version Signed-off-by: sfelipe * Add helper function Signed-off-by: sfelipe * Add forcePassword logic Signed-off-by: sfelipe --------- Signed-off-by: sfelipe --- bitnami/mariadb/Chart.yaml | 2 +- bitnami/mariadb/templates/_helpers.tpl | 10 ++++++++++ bitnami/mariadb/templates/secrets.yaml | 9 ++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bitnami/mariadb/Chart.yaml b/bitnami/mariadb/Chart.yaml index 096a9fd37a..4a82f84b1e 100644 --- a/bitnami/mariadb/Chart.yaml +++ b/bitnami/mariadb/Chart.yaml @@ -26,4 +26,4 @@ sources: - https://github.com/bitnami/containers/tree/main/bitnami/mariadb - https://github.com/prometheus/mysqld_exporter - https://mariadb.org -version: 12.1.3 +version: 12.1.4 diff --git a/bitnami/mariadb/templates/_helpers.tpl b/bitnami/mariadb/templates/_helpers.tpl index 49cb4a4757..d940b5ac6f 100644 --- a/bitnami/mariadb/templates/_helpers.tpl +++ b/bitnami/mariadb/templates/_helpers.tpl @@ -147,3 +147,13 @@ mariadb: architecture "replication". Please set a valid architecture (--set architecture="xxxx") {{- end -}} {{- end -}} + +{{/* +Get existing password to access MariaDB +*/}} +{{- define "mariadb.secret.existPassword" -}} +{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "mariadb.secretName" .)).data -}} +{{- if hasKey $secret "mariadb-password" }} + {{- true -}} +{{- end -}} +{{- end -}} diff --git a/bitnami/mariadb/templates/secrets.yaml b/bitnami/mariadb/templates/secrets.yaml index 89f0efed11..67ef178d29 100644 --- a/bitnami/mariadb/templates/secrets.yaml +++ b/bitnami/mariadb/templates/secrets.yaml @@ -1,7 +1,10 @@ {{- $host := include "mariadb.primary.fullname" . }} {{- $port := print .Values.primary.service.ports.mysql }} {{- $rootPassword := include "common.secrets.passwords.manage" (dict "secret" (include "mariadb.secretName" .) "key" "mariadb-root-password" "providedValues" (list "auth.rootPassword") "context" $) | trimAll "\"" | b64dec }} +{{- $password := .Values.auth.password }} +{{- if eq (include "mariadb.secret.existPassword" .) "true" }} {{- $password := include "common.secrets.passwords.manage" (dict "secret" (include "mariadb.secretName" .) "key" "mariadb-password" "providedValues" (list "auth.password") "context" $) | trimAll "\"" | b64dec }} +{{- end }} {{- if eq (include "mariadb.createSecret" .) "true" }} apiVersion: v1 kind: Secret @@ -26,7 +29,7 @@ data: {{- if (not .Values.auth.forcePassword) }} mariadb-password: {{ print $password | b64enc | quote }} {{- else }} - mariadb-password: {{ required "A MariaDB Database Password is required!" .Values.auth.password | b64enc | quote }} + mariadb-password: {{ required "A MariaDB Database Password is required!" $password | b64enc | quote }} {{- end }} {{- end }} {{- if eq .Values.architecture "replication" }} @@ -87,7 +90,11 @@ data: {{- if $database }} database: {{ print $database | b64enc | quote }} {{- end }} + {{- if and (.Values.auth.forcePassword) (empty $password) }} + password: {{ required "A MariaDB Database Password is required!" $password | b64enc | quote }} + {{- else }} password: {{ print $password | b64enc | quote }} + {{- end }} uri: {{ printf "mysql://%s:%s@%s:%s/%s" .Values.auth.username $password $host $port $database | b64enc | quote }} {{- end }} {{- end }}