From a03f11b36c52c7906ca38aafa101d64afbc07e30 Mon Sep 17 00:00:00 2001 From: Tomas Pizarro Date: Fri, 16 Mar 2018 18:24:24 +0100 Subject: [PATCH] [stable/moodle] Allow use of external database (#4184) * [stable/moodle] Allow use of external database * Add missing secrets file * Add mariabdRootPassword property * Fix typo * Update image tag * Delete trailing space --- stable/moodle/Chart.yaml | 2 +- stable/moodle/README.md | 12 +++++- stable/moodle/requirements.lock | 4 +- stable/moodle/requirements.yaml | 1 + stable/moodle/templates/NOTES.txt | 17 ++++++++ stable/moodle/templates/deployment.yaml | 26 ++++++++++- .../moodle/templates/externaldb-secrets.yaml | 14 ++++++ stable/moodle/values.yaml | 43 ++++++++++++++++++- 8 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 stable/moodle/templates/externaldb-secrets.yaml diff --git a/stable/moodle/Chart.yaml b/stable/moodle/Chart.yaml index 2086ed789b..cee1462821 100644 --- a/stable/moodle/Chart.yaml +++ b/stable/moodle/Chart.yaml @@ -1,5 +1,5 @@ name: moodle -version: 0.4.7 +version: 0.5.0 appVersion: 3.4.1 description: Moodle is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised diff --git a/stable/moodle/README.md b/stable/moodle/README.md index fdb3c8943a..2a524cca43 100644 --- a/stable/moodle/README.md +++ b/stable/moodle/README.md @@ -69,7 +69,17 @@ The following tables lists the configurable parameters of the Moodle chart and t | `persistence.accessMode` | PVC Access Mode for Moodle volume | `ReadWriteOnce` | | `persistence.size` | PVC Storage Request for Moodle volume | `8Gi` | | `persistence.existingClaim` | If PVC exists&bounded for Moodle | `nil` (when nil, new one is requested) | -| `mariadb.mariadbRootPassword` | MariaDB admin password | `nil` (uses alpha storage class annotation) | +| `allowEmptyPassword` | Allow DB blank passwords | `yes` | +| `externalDatabase.host` | Host of the external database | `nil` | +| `externalDatabase.port` | Port of the external database | `3306` | +| `externalDatabase.user` | Existing username in the external db | `bn_moodle` | +| `externalDatabase.password` | Password for the above username | `nil` | +| `externalDatabase.database` | Name of the existing databse | `bitnami_moodle` | +| `mariadb.enabled` | Wheter to use or not the mariadb chart | `true` | +| `mariadb.mariadbDatabase` | Database name to create | `bitnami_moodle` | +| `mariadb.mariadbUser` | Database user to create | `bn_moodle` | +| `mariadb.mariadbPassword` | Password for the database | `nil` | +| `mariadb.mariadbRootPassword` | MariaDB admin password | `nil` | | `mariadb.persistence.enabled` | Enable MariaDB persistence using PVC | `true` | | `mariadb.persistence.storageClass` | PVC Storage Class for MariaDB volume | `generic` | | `mariadb.persistence.accessMode` | PVC Access Mode for MariaDB volume | `ReadWriteOnce` | diff --git a/stable/moodle/requirements.lock b/stable/moodle/requirements.lock index 45374cccde..eea783d0cb 100644 --- a/stable/moodle/requirements.lock +++ b/stable/moodle/requirements.lock @@ -2,5 +2,5 @@ dependencies: - name: mariadb repository: https://kubernetes-charts.storage.googleapis.com/ version: 0.7.0 -digest: sha256:e1af13ac4ac21f67582006f12d2b4eb78a1a2a59b34338fac850f2bec0b08b41 -generated: 2017-08-09T22:52:52.983181778-04:00 +digest: sha256:f59f68030aa5c50b9e776b813804875fac911f91c2aa384e991f37a795c5ae34 +generated: 2018-03-15T13:58:06.682767+01:00 diff --git a/stable/moodle/requirements.yaml b/stable/moodle/requirements.yaml index 4896aa89de..7c0c6a88a9 100644 --- a/stable/moodle/requirements.yaml +++ b/stable/moodle/requirements.yaml @@ -2,3 +2,4 @@ dependencies: - name: mariadb version: 0.7.0 repository: https://kubernetes-charts.storage.googleapis.com/ + condition: mariadb.enabled diff --git a/stable/moodle/templates/NOTES.txt b/stable/moodle/templates/NOTES.txt index f6b7160c86..d1ac1b2348 100644 --- a/stable/moodle/templates/NOTES.txt +++ b/stable/moodle/templates/NOTES.txt @@ -1,4 +1,5 @@ +{{- if or .Values.mariadb.enabled .Values.externalDatabase.host -}} ** Please be patient while the chart is being deployed ** {{- if and .Values.ingress.enabled (ne .Values.serviceType "ClusterIP") }} ** Notice : Usually with ingress the serviceType should be set to ClusterIP, which is not the case to this deployment! ** @@ -39,3 +40,19 @@ echo Username: {{ .Values.moodleUsername }} echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "moodle.fullname" . }} -o jsonpath="{.data.moodle-password}" | base64 --decode) + +{{- else -}} + +######################################################################################## +### ERROR: You did not provide an external database host in your 'helm install' call ### +######################################################################################## + +This deployment will be incomplete until you configure Moodle with a resolvable database +host. To configure Moodle to use and external database host: + + +1. Complete your Moodle deployment by running: + + helm upgrade {{ .Release.Name }} --set serviceType={{ .Values.serviceType }},mariadb.enabled=false,externalDatabase.host=YOUR_EXTERNAL_DATABASE_HOST stable/moodle + +{{- end }} \ No newline at end of file diff --git a/stable/moodle/templates/deployment.yaml b/stable/moodle/templates/deployment.yaml index cbdb198181..0858396922 100644 --- a/stable/moodle/templates/deployment.yaml +++ b/stable/moodle/templates/deployment.yaml @@ -22,15 +22,37 @@ spec: image: "{{ .Values.image }}" imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }} env: + - name: ALLOW_EMPTY_PASSWORD + value: {{ .Values.allowEmptyPassword | quote }} + {{- if .Values.mariadb.enabled }} - name: MARIADB_HOST value: {{ template "moodle.mariadb.fullname" . }} - name: MARIADB_PORT_NUMBER value: "3306" - - name: MARIADB_PASSWORD + - name: MOODLE_DATABASE_NAME + value: {{ .Values.mariadb.mariadbDatabase | quote }} + - name: MOODLE_DATABASE_USER + value: {{ .Values.mariadb.mariadbUser | quote }} + - name: MOODLE_DATABASE_PASSWORD valueFrom: secretKeyRef: name: {{ template "moodle.mariadb.fullname" . }} - key: mariadb-root-password + key: mariadb-password + {{- else }} + - name: MARIADB_HOST + value: {{ .Values.externalDatabase.host | quote }} + - name: MARIADB_PORT_NUMBER + value: {{ .Values.externalDatabase.port | quote }} + - name: MOODLE_DATABASE_NAME + value: {{ .Values.externalDatabase.database | quote }} + - name: MOODLE_DATABASE_USER + value: {{ .Values.externalDatabase.user | quote }} + - name: MOODLE_DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ printf "%s-%s" .Release.Name "externaldb" }} + key: db-password + {{- end }} - name: MOODLE_USERNAME value: {{ default "" .Values.moodleUsername | quote }} - name: MOODLE_PASSWORD diff --git a/stable/moodle/templates/externaldb-secrets.yaml b/stable/moodle/templates/externaldb-secrets.yaml new file mode 100644 index 0000000000..4ceb148898 --- /dev/null +++ b/stable/moodle/templates/externaldb-secrets.yaml @@ -0,0 +1,14 @@ +{{- if not .Values.mariadb.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ printf "%s-%s" .Release.Name "externaldb" }} + labels: + app: {{ printf "%s-%s" .Release.Name "externaldb" }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + db-password: {{ default "" .Values.externalDatabase.password | b64enc | quote }} +{{- end }} \ No newline at end of file diff --git a/stable/moodle/values.yaml b/stable/moodle/values.yaml index 3f3ac73b61..3af1e4ed50 100644 --- a/stable/moodle/values.yaml +++ b/stable/moodle/values.yaml @@ -1,7 +1,7 @@ ## Bitnami Moodle` image version ## ref: https://hub.docker.com/r/bitnami/moodle/tags/ ## -image: bitnami/moodle:3.4.1-r3 +image: bitnami/moodle:3.4.1-r4 ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' @@ -24,6 +24,29 @@ moodleUsername: user ## ref: https://github.com/bitnami/bitnami-docker-moodle#configuration moodleEmail: user@example.com +## Set to `yes` to allow the container to be started with blank passwords +## ref: https://github.com/bitnami/bitnami-docker-moodle#environment-variables +allowEmptyPassword: "yes" + +## +## External database configuration +## +externalDatabase: + ## Database host + host: + + ## Database host + port: 3306 + + ## Database user + user: bn_moodle + + ## Database password + password: + + ## Database name + database: bitnami_moodle + ## SMTP mail delivery configuration ## ref: https://github.com/bitnami/bitnami-docker-moodle/#smtp-configuration # smtpHost: @@ -36,6 +59,24 @@ moodleEmail: user@example.com ## MariaDB chart configuration ## mariadb: + ## Whether to deploy a mariadb server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters + enabled: true + + ## Create a database + ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-on-first-run + ## + mariadbDatabase: bitnami_moodle + + ## Create a database user + ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-user-on-first-run + ## + mariadbUser: bn_moodle + + ## Password for mariadbUser + ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-user-on-first-run + ## + # mariadbPassword: + ## MariaDB admin password ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run ##