From 6af2cc755eeed224a43975aca57348889169171a Mon Sep 17 00:00:00 2001 From: Pan Luo Date: Tue, 29 Oct 2024 15:51:56 -0700 Subject: [PATCH] Make existing secret name customizable --- moodle/Chart.yaml | 2 +- moodle/templates/_helpers.tpl | 26 +++++++++++++++++++++----- moodle/templates/cronjob.yaml | 2 +- moodle/templates/deployment.yaml | 2 +- moodle/values.yaml | 1 + 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/moodle/Chart.yaml b/moodle/Chart.yaml index 4a3a25c..63e0fff 100644 --- a/moodle/Chart.yaml +++ b/moodle/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: moodle -version: 0.1.11 +version: 0.1.12 description: Moodle is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised learning environments keywords: - moodle diff --git a/moodle/templates/_helpers.tpl b/moodle/templates/_helpers.tpl index 9ee164d..a193e81 100644 --- a/moodle/templates/_helpers.tpl +++ b/moodle/templates/_helpers.tpl @@ -42,6 +42,22 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- end -}} {{- end -}} +{{- define "moodle.db.secretname" -}} +{{- if .Values.db.auth.existingSecret }} +{{- .Values.db.auth.existingSecret -}} +{{- else -}} +{{ include "call-nested" (list . "db" "common.names.fullname") }} +{{- end -}} +{{- end -}} + +{{- define "moodle.secretname" -}} +{{- if .Values.moodleExistingSecret }} +{{- .Values.moodleExistingSecret -}} +{{- else -}} +{{ template "moodle.fullname" . }} +{{- end -}} +{{- end -}} + {{- define "common_labels" }} app: {{ template "moodle.fullname" . }} stage: {{ .Values.stage }} @@ -106,7 +122,7 @@ env: valueFrom: secretKeyRef: {{- if .Values.db.disableExternal }} - name: {{ include "call-nested" (list . "db" "common.names.fullname") }} + name: {{ template "moodle.db.secretname" }} key: mariadb-password {{- else }} name: {{ template "moodle.fullname" . }} @@ -125,7 +141,7 @@ env: - name: MOODLE_ADMIN_PASS valueFrom: secretKeyRef: - name: {{ template "moodle.fullname" . }} + name: {{ template "moodle.secretname" . }} key: moodle_password - name: MOODLE_ADMIN_EMAIL value: {{ default "" .Values.moodleEmail | quote }} @@ -146,7 +162,7 @@ env: - name: SMTP_PASSWORD valueFrom: secretKeyRef: - name: {{ template "moodle.fullname" . }} + name: {{ template "moodle.secretname" . }} key: smtp_password - name: SMTP_PROTOCOL value: {{ default "" .Values.smtpProtocol | quote }} @@ -166,7 +182,7 @@ env: valueFrom: secretKeyRef: {{- if .Values.db.disableExternal }} - name: {{ include "call-nested" (list . "db" "common.names.fullname") }} + name: {{ template "moodle.db.secretname" }} key: mariadb-password {{- else }} name: {{ template "moodle.fullname" . }} @@ -252,7 +268,7 @@ env: valueFrom: secretKeyRef: {{- if .Values.db.disableExternal }} - name: {{ include "call-nested" (list . "db" "common.names.fullname") }} + name: {{ template "moodle.db.secretname" }} key: mariadb-password {{- else }} name: {{ template "moodle.fullname" . }} diff --git a/moodle/templates/cronjob.yaml b/moodle/templates/cronjob.yaml index 38a39ea..1337cea 100644 --- a/moodle/templates/cronjob.yaml +++ b/moodle/templates/cronjob.yaml @@ -65,7 +65,7 @@ spec: valueFrom: secretKeyRef: {{- if .Values.db.disableExternal }} - name: {{ include "call-nested" (list . "db" "common.names.fullname") }} + name: {{ template "moodle.db.secretname" }} key: mariadb-password {{- else }} name: {{ template "moodle.fullname" . }} diff --git a/moodle/templates/deployment.yaml b/moodle/templates/deployment.yaml index 2aaf4e3..6298087 100644 --- a/moodle/templates/deployment.yaml +++ b/moodle/templates/deployment.yaml @@ -242,7 +242,7 @@ spec: valueFrom: secretKeyRef: {{- if .Values.db.disableExternal }} - name: {{ include "call-nested" (list . "db" "common.names.fullname") }} + name: {{ template "moodle.db.secretname" }} key: mariadb-password {{- else }} name: {{ template "moodle.fullname" . }} diff --git a/moodle/values.yaml b/moodle/values.yaml index ac58b0d..d41042c 100644 --- a/moodle/values.yaml +++ b/moodle/values.yaml @@ -105,6 +105,7 @@ db: # password: &dbPass # replicationUser: replicator # replicationPassword: + # existingSecret: ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/