From ff6684e6c9733b1f6cac9f4ccd43a03ca25fe626 Mon Sep 17 00:00:00 2001 From: Nicolas Camus Date: Tue, 15 Oct 2019 11:47:51 +0200 Subject: [PATCH] [stable/mariadb] Fix the command generated to retrieve the administrator password in NOTES.txt (#17954) Signed-off-by: Nicolas Camus --- stable/mariadb/Chart.yaml | 2 +- stable/mariadb/templates/NOTES.txt | 4 ++-- stable/mariadb/templates/_helpers.tpl | 11 +++++++++ .../mariadb/templates/master-statefulset.yaml | 24 ++++--------------- .../mariadb/templates/slave-statefulset.yaml | 18 +++----------- stable/mariadb/templates/test-runner.yaml | 6 +---- 6 files changed, 22 insertions(+), 43 deletions(-) diff --git a/stable/mariadb/Chart.yaml b/stable/mariadb/Chart.yaml index 62b0b540e6..7ad79fa4f4 100644 --- a/stable/mariadb/Chart.yaml +++ b/stable/mariadb/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: mariadb -version: 6.11.1 +version: 6.11.2 appVersion: 10.3.18 description: Fast, reliable, scalable, and easy to use open-source relational database system. MariaDB Server is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software. Highly available MariaDB cluster. keywords: diff --git a/stable/mariadb/templates/NOTES.txt b/stable/mariadb/templates/NOTES.txt index f4621de5b3..b69ecefc26 100644 --- a/stable/mariadb/templates/NOTES.txt +++ b/stable/mariadb/templates/NOTES.txt @@ -15,7 +15,7 @@ Services: Administrator credentials: Username: root - Password : $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mariadb.fullname" . }} -o jsonpath="{.data.mariadb-root-password}" | base64 --decode) + Password : $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mariadb.secretName" . }} -o jsonpath="{.data.mariadb-root-password}" | base64 --decode) To connect to your database: @@ -38,7 +38,7 @@ To upgrade this helm chart: 1. Obtain the password as described on the 'Administrator credentials' section and set the 'rootUser.password' parameter as shown below: - ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mariadb.fullname" . }} -o jsonpath="{.data.mariadb-root-password}" | base64 --decode) + ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mariadb.secretName" . }} -o jsonpath="{.data.mariadb-root-password}" | base64 --decode) helm upgrade {{ .Release.Name }} stable/mariadb --set rootUser.password=$ROOT_PASSWORD {{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }} diff --git a/stable/mariadb/templates/_helpers.tpl b/stable/mariadb/templates/_helpers.tpl index 52603da8d1..e5b0895973 100644 --- a/stable/mariadb/templates/_helpers.tpl +++ b/stable/mariadb/templates/_helpers.tpl @@ -242,3 +242,14 @@ but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else {{- end -}} {{- end -}} {{- end -}} + +{{/* +Return the name of the Secret used to store the passwords +*/}} +{{- define "mariadb.secretName" -}} +{{- if .Values.existingSecret -}} +{{ .Values.existingSecret }} +{{- else -}} +{{ template "mariadb.fullname" . -}} +{{- end -}} +{{- end -}} diff --git a/stable/mariadb/templates/master-statefulset.yaml b/stable/mariadb/templates/master-statefulset.yaml index 074f2a5a01..1541d47e76 100644 --- a/stable/mariadb/templates/master-statefulset.yaml +++ b/stable/mariadb/templates/master-statefulset.yaml @@ -117,11 +117,7 @@ spec: - name: MARIADB_ROOT_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-root-password {{- if .Values.db.user }} - name: MARIADB_USER @@ -129,11 +125,7 @@ spec: - name: MARIADB_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-password {{- end }} - name: MARIADB_DATABASE @@ -146,11 +138,7 @@ spec: - name: MARIADB_REPLICATION_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-replication-password {{- end }} ports: @@ -201,11 +189,7 @@ spec: - name: MARIADB_ROOT_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-root-password command: - sh diff --git a/stable/mariadb/templates/slave-statefulset.yaml b/stable/mariadb/templates/slave-statefulset.yaml index bcb4309d3f..28a2ac103e 100644 --- a/stable/mariadb/templates/slave-statefulset.yaml +++ b/stable/mariadb/templates/slave-statefulset.yaml @@ -126,22 +126,14 @@ spec: - name: MARIADB_MASTER_ROOT_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-root-password - name: MARIADB_REPLICATION_USER value: "{{ .Values.replication.user }}" - name: MARIADB_REPLICATION_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-replication-password ports: - name: mysql @@ -184,11 +176,7 @@ spec: - name: MARIADB_ROOT_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-root-password command: - sh diff --git a/stable/mariadb/templates/test-runner.yaml b/stable/mariadb/templates/test-runner.yaml index c9821ced37..658d62bb70 100644 --- a/stable/mariadb/templates/test-runner.yaml +++ b/stable/mariadb/templates/test-runner.yaml @@ -27,11 +27,7 @@ spec: - name: MARIADB_ROOT_PASSWORD valueFrom: secretKeyRef: - {{- if .Values.existingSecret }} - name: {{ .Values.existingSecret }} - {{- else }} - name: {{ template "mariadb.fullname" . }} - {{- end }} + name: {{ template "mariadb.secretName" . }} key: mariadb-root-password volumeMounts: - mountPath: /tests