From 383cef47903bd751c74fb03e28b48a235dfbdefa Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Fri, 8 Nov 2024 11:37:13 +0000 Subject: [PATCH 1/8] make secret name hardcoded to moodle --- charts/dbp-moodle/templates/secrets/moodle-secret.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/dbp-moodle/templates/secrets/moodle-secret.yaml b/charts/dbp-moodle/templates/secrets/moodle-secret.yaml index 67a3f4b..c5fe038 100644 --- a/charts/dbp-moodle/templates/secrets/moodle-secret.yaml +++ b/charts/dbp-moodle/templates/secrets/moodle-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret type: Opaque metadata: - name: "{{ .Release.Name }}" + name: "moodle" namespace: "{{ .Release.Namespace }}" stringData: moodle-password: {{ include "dbpMoodle.secrets.moodle_password" . }} From bba5cb73d14888deed4c6efb02a76cdaf62596fa Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Fri, 8 Nov 2024 11:39:32 +0000 Subject: [PATCH 2/8] disable update preperation job if update migration is disabled --- .../templates/chart-hooks/moodle-update-preparation-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml b/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml index f710d22..1294893 100644 --- a/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml +++ b/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml @@ -1,4 +1,4 @@ -{{ if not .Values.dbpMoodle.restore.enabled }} +{{ if and Values.dbpMoodle.update_migration.enabled (not .Values.dbpMoodle.restore.enabled) }} apiVersion: batch/v1 kind: Job metadata: From 53fc92e84aef6f15206b57f52d61863b5985d713 Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Mon, 11 Nov 2024 09:24:17 +0000 Subject: [PATCH 3/8] refactor values to make more clear which settings affect the config.php, fix some whitespace issues in config.php as well --- charts/dbp-moodle/scripts/config.php | 17 ++++++++--------- charts/dbp-moodle/values.yaml | 5 +++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/charts/dbp-moodle/scripts/config.php b/charts/dbp-moodle/scripts/config.php index d1c839c..985edc5 100644 --- a/charts/dbp-moodle/scripts/config.php +++ b/charts/dbp-moodle/scripts/config.php @@ -42,27 +42,26 @@ require_once(__DIR__ . '/lib/setup.php'); -{{ if .Values.dbpMoodle.logging }} -define('MDL_PERF' , true); -define('MDL_PERFDB' , true); -define('MDL_PERFTOLOG' , true); //OK for production -{{ end }} - +{{- if .Values.dbpMoodle.phpConfig.extendedLogging }} +define('MDL_PERF' , true); +define('MDL_PERFDB' , true); +define('MDL_PERFTOLOG' , true); //OK for production +{{- end }} -{{ if .Values.dbpMoodle.debug }} +{{ if .Values.dbpMoodle.phpConfig.debug -}} @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS! @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS! $CFG->debug = 32767; // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS! $CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS! $CFG->debugpageinfo = 1; $CFG->perfdebug = 7; -{{ else }} +{{- else -}} $CFG->debug = 0; $CFG->debugdisplay = 0; $CFG->debugpageinfo = 0; $CFG->perfdebug = 7; $CFG->debugsqltrace = 0; -{{ end }} +{{- end }} // There is no php closing tag in this file, // it is intentional because it prevents trailing whitespace problems! \ No newline at end of file diff --git a/charts/dbp-moodle/values.yaml b/charts/dbp-moodle/values.yaml index 7a9d5f2..4fd4b62 100644 --- a/charts/dbp-moodle/values.yaml +++ b/charts/dbp-moodle/values.yaml @@ -75,6 +75,11 @@ dbpMoodle: update_migration: enabled: false + phpConfig: + # -- Extended php logging + extendedLogging: false + # -- Moodle debugging is not safe for production + debug: false # -- Configurations for the optional redis redis: host: "moodle-redis-master" From 269905dcd293cc1592126f8f0d4cb9bcf449f738 Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Mon, 11 Nov 2024 09:25:42 +0000 Subject: [PATCH 4/8] Add value to include arbitrary options into config.php --- charts/dbp-moodle/scripts/config.php | 3 +++ charts/dbp-moodle/values.yaml | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/charts/dbp-moodle/scripts/config.php b/charts/dbp-moodle/scripts/config.php index 985edc5..752375b 100644 --- a/charts/dbp-moodle/scripts/config.php +++ b/charts/dbp-moodle/scripts/config.php @@ -63,5 +63,8 @@ $CFG->debugsqltrace = 0; {{- end }} +{{ with .Values.dbpMoodle.phpConfig.additional -}} +{{- . }} +{{- end }} // There is no php closing tag in this file, // it is intentional because it prevents trailing whitespace problems! \ No newline at end of file diff --git a/charts/dbp-moodle/values.yaml b/charts/dbp-moodle/values.yaml index 4fd4b62..78da2cf 100644 --- a/charts/dbp-moodle/values.yaml +++ b/charts/dbp-moodle/values.yaml @@ -66,10 +66,6 @@ global: dbpMoodle: name: infra stage: infra - # -- Extended php logging - logging: false - # -- Moodle debugging is not safe for production - debug: false # -- The dbp update process to migrate moodle data when moodle versions are increased update_migration: @@ -80,6 +76,10 @@ dbpMoodle: extendedLogging: false # -- Moodle debugging is not safe for production debug: false + additional: | + $CFG->sslproxy = 1; + $CFG->someotheroption = "whatever value"; + # -- Configurations for the optional redis redis: host: "moodle-redis-master" From ab405c43d6801b4ce1e25ca021a5e7fe95f26c3e Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Mon, 11 Nov 2024 09:26:18 +0000 Subject: [PATCH 5/8] change if condition to respect update_migration value --- .../templates/chart-hooks/moodle-update-preparation-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml b/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml index 1294893..fecf2b9 100644 --- a/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml +++ b/charts/dbp-moodle/templates/chart-hooks/moodle-update-preparation-job.yaml @@ -1,4 +1,4 @@ -{{ if and Values.dbpMoodle.update_migration.enabled (not .Values.dbpMoodle.restore.enabled) }} +{{ if and .Values.dbpMoodle.update_migration.enabled (not .Values.dbpMoodle.restore.enabled) }} apiVersion: batch/v1 kind: Job metadata: From 25768393eb3158a82573a511ff27c849746346fe Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Mon, 11 Nov 2024 09:26:38 +0000 Subject: [PATCH 6/8] set default for redis.enabled to false --- charts/dbp-moodle/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/dbp-moodle/values.yaml b/charts/dbp-moodle/values.yaml index 78da2cf..c41f042 100644 --- a/charts/dbp-moodle/values.yaml +++ b/charts/dbp-moodle/values.yaml @@ -383,7 +383,7 @@ postgresql: # redis helm chart values redis: - enabled: true + enabled: false architecture: "standalone" auth: enabled: true From 6aeda52694cccb3b23dc94814fa877995fd35f04 Mon Sep 17 00:00:00 2001 From: Jannik Badenhop Date: Mon, 11 Nov 2024 09:28:05 +0000 Subject: [PATCH 7/8] add comment for phpConfig.additional and set its default to be empty string --- charts/dbp-moodle/values.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/charts/dbp-moodle/values.yaml b/charts/dbp-moodle/values.yaml index c41f042..0678fe6 100644 --- a/charts/dbp-moodle/values.yaml +++ b/charts/dbp-moodle/values.yaml @@ -76,9 +76,8 @@ dbpMoodle: extendedLogging: false # -- Moodle debugging is not safe for production debug: false - additional: | - $CFG->sslproxy = 1; - $CFG->someotheroption = "whatever value"; + # -- Any additional text to be included into the config.php + additional: "" # -- Configurations for the optional redis redis: From 0dce331e5893bf20a8ce6a3736ffe1763791063b Mon Sep 17 00:00:00 2001 From: devops Date: Mon, 11 Nov 2024 09:38:37 +0000 Subject: [PATCH 8/8] Updating README.md via GithubActions (helm-docs) --- charts/dbp-moodle/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/charts/dbp-moodle/README.md b/charts/dbp-moodle/README.md index 609e8a2..3cddc8d 100644 --- a/charts/dbp-moodle/README.md +++ b/charts/dbp-moodle/README.md @@ -89,7 +89,6 @@ The Chart can be deployed without any modification but it is advised to set own | dbpMoodle.backup.retention_time | string | `"6M"` | Defines the maximum age of a backup before it is deleted | | dbpMoodle.backup.secrets | object | `{"existingSecret":"","s3_access_key":"","s3_access_secret":"","s3_endpoint_url":""}` | Either provide an existing secret, or set each secret value here. If both are set the existingSecret is used | | dbpMoodle.backup.secrets.existingSecret | string | `""` | Existing secret for s3 endpoint | -| dbpMoodle.debug | bool | `false` | Moodle debugging is not safe for production | | dbpMoodle.external_pvc.accessModes[0] | string | `"ReadWriteMany"` | | | dbpMoodle.external_pvc.annotations."helm.sh/resource-policy" | string | `"keep"` | | | dbpMoodle.external_pvc.enabled | bool | `true` | | @@ -101,7 +100,6 @@ The Chart can be deployed without any modification but it is advised to set own | dbpMoodle.hpa.scaledown_value | int | `25` | The max amount in percent to scale down in one step per cooldown period | | dbpMoodle.hpa.scaleup_cooldown | int | `15` | How many seconds to wait between upscaling adjustments | | dbpMoodle.hpa.scaleup_value | int | `50` | The max amount in percent to scale up in one step per cooldown period | -| dbpMoodle.logging | bool | `false` | Extended php logging | | dbpMoodle.moodleUpdatePreparationHook.rules[0].apiGroups[0] | string | `"apps"` | | | dbpMoodle.moodleUpdatePreparationHook.rules[0].resources[0] | string | `"deployments"` | | | dbpMoodle.moodleUpdatePreparationHook.rules[0].verbs[0] | string | `"get"` | | @@ -118,6 +116,9 @@ The Chart can be deployed without any modification but it is advised to set own | dbpMoodle.moodleUpdatePreparationJob.kubectlImage | string | `"bitnami/kubectl:1.30.4-debian-12-r3"` | Which kubectl image to use | | dbpMoodle.moodlecronjob | object | `{"rules":[{"apiGroups":[""],"resources":["pods","pods/exec"],"verbs":["get","list","create","watch"]}],"wait_timeout":"15m"}` | Configuration for the moodle-cronjob which runs moodles cron.php. This is required since moodle does not run as root | | dbpMoodle.name | string | `"infra"` | | +| dbpMoodle.phpConfig.additional | string | `""` | Any additional text to be included into the config.php | +| dbpMoodle.phpConfig.debug | bool | `false` | Moodle debugging is not safe for production | +| dbpMoodle.phpConfig.extendedLogging | bool | `false` | Extended php logging | | dbpMoodle.redis | object | `{"host":"moodle-redis-master","password":"","port":6379}` | Configurations for the optional redis | | dbpMoodle.restore | object | `{"affinity":{},"enabled":false,"existingSecretDatabase":"moodle","existingSecretGPG":"","existingSecretKeyDatabase":"","existingSecretKeyS3Access":"","existingSecretKeyS3Secret":"","existingSecretS3":"","image":"ghcr.io/dbildungsplattform/moodle-tools:1.0.7","resources":{"limits":{"cpu":"2000m","memory":"16Gi"},"requests":{"cpu":"1000m","memory":"8Gi"}},"rules":[{"apiGroups":["apps"],"resources":["deployments/scale","deployments"],"verbs":["get","list","scale","patch"]}],"tolerations":[]}` | This restores moodle to the latest snapshot. Requires an existing s3 backup. ONLY USE FOR ROLLBACK | | dbpMoodle.secrets | object | `{"etherpad_api_key":"","etherpad_postgresql_password":"","mariadb_password":"","mariadb_root_password":"","moodle_password":"","pgsql_admin_password":"","useChartSecret":true}` | Creates a secret with all relevant credentials for moodle -- Set useChartSecret: false to provide your own secret -- If you create your own secret, also set moodle.existingSecret (and moodle.externalDatabase.existingSecret if you bring your own DB) | @@ -314,7 +315,7 @@ The Chart can be deployed without any modification but it is advised to set own | redis.auth.existingSecret | string | `"moodle"` | | | redis.auth.existingSecretPasswordKey | string | `"redis-password"` | | | redis.auth.usePasswordFileFromSecret | bool | `true` | | -| redis.enabled | bool | `true` | | +| redis.enabled | bool | `false` | | | redis.master.affinity | object | `{}` | | | redis.master.resources | object | `{}` | | | redis.master.tolerations | list | `[]` | |