[bitnami/mariadb] Fix mariadb upgrade (#16265)

* Fix mariadb upgrade

Signed-off-by: sfelipe <sfelipe@vmware.com>

* Bump chart version

Signed-off-by: sfelipe <sfelipe@vmware.com>

* Add helper function

Signed-off-by: sfelipe <sfelipe@vmware.com>

* Add forcePassword logic

Signed-off-by: sfelipe <sfelipe@vmware.com>

---------

Signed-off-by: sfelipe <sfelipe@vmware.com>
This commit is contained in:
Felipe V.C. Serafim
2023-05-03 10:59:57 +02:00
committed by GitHub
parent eff20e2b81
commit b4262dbaae
3 changed files with 19 additions and 2 deletions

View File

@@ -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

View File

@@ -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 -}}

View File

@@ -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 }}