From 2407081bba608f941344253c631b4db1be16448c Mon Sep 17 00:00:00 2001
From: Arie Peterson <arie@greenhost.nl>
Date: Thu, 23 Sep 2021 12:07:56 +0200
Subject: [PATCH] Bump mariadb to 9.6.0

---
 CHANGELOG.md               | 11 +++++++++++
 Chart.yaml                 |  2 +-
 README.md                  |  8 ++++----
 templates/statefulset.yaml | 12 ++++++------
 values-local.yaml.example  | 10 ++++------
 values.yaml                | 23 ++++++++++++-----------
 6 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index cbae847..55a779e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+## Unreleased
+
+* Update mariadb chart to 9.6.0
+  NOTE: the mariadb chart does not provide backwards compatibility in this
+  case, so manual action is required if you want to upgrade an existing
+  wordpress-helm release to this new version: either by migrating database data
+  from the old release to the new one, or by using the `existingClaim`
+  parameter(s) to reuse the existing persistent volumes. For details, see
+  [mariadb chart upgrade notes](
+  https://artifacthub.io/packages/helm/bitnami/mariadb/9.6.0#to-8-0-0)
+
 ## [0.2.1] - 2021-09-16
 
 * Allow setting custom labels on pods and statefulset
diff --git a/Chart.yaml b/Chart.yaml
index a60676f..217dd61 100644
--- a/Chart.yaml
+++ b/Chart.yaml
@@ -9,7 +9,7 @@ version: 0.2.1
 icon: https://make.wordpress.org/design/files/2016/09/WordPress-logotype-wmark.png
 dependencies:
   - name: mariadb
-    version: 7.3.16
+    version: 9.6.0
     repository: "https://charts.bitnami.com/bitnami"
     tags:
       - mysql
diff --git a/README.md b/README.md
index 861420e..5243d15 100644
--- a/README.md
+++ b/README.md
@@ -38,10 +38,10 @@ For a simple WordPress installation, you only need to edit the following values:
 | `ansibleVars.WP_TITLE`                | The title of the site                         | Demo WP                           |
 | `ansibleVars.WP_THEME_ACTIVE`                | A *slug* for the theme you want to install on your site (can also be changed through interface) | twentytwenty |
 | `ansibleVars.WP_EMAIL`                | The administrator's email adress              | youremailhere@example.com         |
-| `database.db.user`                    | Database user                                 | wordpress                         |
-| `database.db.password`                | `wordpress` db user password                  | You **really** need to set this   |
-| `database.db.rootUser.password `      | root user password                            | You **really** need to set this   |
-| `database.db.replicationUser.password`| replication user password                     | You **really** need to set this   |
+| `database.auth.username`              | Database user                                 | wordpress                         |
+| `database.auth.password`              | `wordpress` db user password                  | You **really** need to set this   |
+| `database.auth.rootPassword `         | root user password                            | You **really** need to set this   |
+| `database.auth.replicationPassword`   | replication user password                     | You **really** need to set this   |
 
 You can read the descriptions of the other variables in
 `values-local.yaml.example` and of even more variables in `values.yaml`.
diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml
index 7254825..2a5666c 100644
--- a/templates/statefulset.yaml
+++ b/templates/statefulset.yaml
@@ -62,14 +62,14 @@ spec:
             - name: WORDPRESS_DB_HOST
               value: {{ .Release.Name }}-database
             - name: WORDPRESS_DB_USER
-              value: {{ .Values.database.db.user }}
+              value: {{ .Values.database.auth.username }}
             - name: WORDPRESS_DB_PASSWORD
               valueFrom:
                 secretKeyRef:
                   name: {{ .Release.Name }}-database
                   key: mariadb-password
             - name: WORDPRESS_DB_NAME
-              value: {{ .Values.database.db.name }}
+              value: {{ .Values.database.auth.database }}
             - name: WORDPRESS_TABLE_PREFIX
               value: {{ .Values.wordPressTablePrefix }}
       containers:
@@ -108,14 +108,14 @@ spec:
             - name: WORDPRESS_DB_HOST
               value: {{ .Release.Name }}-database
             - name: WORDPRESS_DB_USER
-              value: {{ .Values.database.db.user }}
+              value: {{ .Values.database.auth.username }}
             - name: WORDPRESS_DB_PASSWORD
               valueFrom:
                 secretKeyRef:
                   name: {{ .Release.Name }}-database
                   key: mariadb-password
             - name: WORDPRESS_DB_NAME
-              value: {{ .Values.database.db.name }}
+              value: {{ .Values.database.auth.database }}
             - name: WORDPRESS_TABLE_PREFIX
               value: {{ .Values.wordPressTablePrefix }}
           # readinessProbe:
@@ -144,14 +144,14 @@ spec:
             - name: WORDPRESS_DB_HOST
               value: {{ .Release.Name }}-database
             - name: WORDPRESS_DB_USER
-              value: {{ .Values.database.db.user }}
+              value: {{ .Values.database.auth.username }}
             - name: WORDPRESS_DB_PASSWORD
               valueFrom:
                 secretKeyRef:
                   name: {{ .Release.Name }}-database
                   key: mariadb-password
             - name: WORDPRESS_DB_NAME
-              value: {{ .Values.database.db.name }}
+              value: {{ .Values.database.auth.database }}
             - name: WORDPRESS_TABLE_PREFIX
               value: {{ .Values.wordPressTablePrefix }}
             - name: BACKUP_INTERVAL_SECONDS
diff --git a/values-local.yaml.example b/values-local.yaml.example
index 82d0bd1..4c78587 100644
--- a/values-local.yaml.example
+++ b/values-local.yaml.example
@@ -118,13 +118,11 @@ openid_connect_settings:
   role_key: roles
 
 database:
-  db:
-    user: wordpress
+  auth:
+    username: wordpress
     password: <SET A DATABASE PASSWORD>
-  rootUser:
-    password: <SET A DB ROOT USER PASSWORD FOR UPGRADES TO WORK>
-  replication:
-    password: <SET A REPLICATION USER PASSWORD IF YOU HAVE REPLICATION ENABLED>
+    rootPassword: <SET A DB ROOT USER PASSWORD FOR UPGRADES TO WORK>
+    replicationPassword: <SET A REPLICATION USER PASSWORD IF YOU HAVE REPLICATION ENABLED>
 
 # Set this to true to have a Redis container next to your WP. The WP will be
 # configured to connect to this Redis and `Redis Object Cache` plugin will be
diff --git a/values.yaml b/values.yaml
index 95a9ffa..f749130 100644
--- a/values.yaml
+++ b/values.yaml
@@ -264,14 +264,14 @@ nodeSelector: {}
 tolerations: []
 
 affinity: {}
+
 database:
-  db:
-    user: wordpress
+  auth:
+    username: wordpress
     password: CHANGE-THIS-PASSWORD
-    name: wordpress_db
-  replication:
-    enabled: true
-  master:
+    database: wordpress_db
+  architecture: replication
+  primary:
     persistence:
       size: 4Gi
     config: |-
@@ -295,7 +295,7 @@ database:
       [manager]
       port=3306
       socket=/opt/bitnami/mariadb/tmp/mysql.sock
-  slave:
+  secondary:
     persistence:
       size: 4Gi
     config: |-
@@ -319,6 +319,7 @@ database:
       [manager]
       port=3306
       socket=/opt/bitnami/mariadb/tmp/mysql.sock
+
 redis:
   # Set redis.enabled to true to have a Redis container next to your WP. The WP will be
   # configured to connect to this Redis and `Redis Object Cache` plugin will be
@@ -348,11 +349,11 @@ ansibleSecrets: |
   BACKUP_NAME: {{ .Release.Name }}
   BACKUP_TARGET: {{ .Values.backup.target }}
   BACKUP_ISDATE: {{ .Values.backup.isDate }}
-  DB_HOST: {{ .Release.Name }}-database
-  DB_NAME: {{ .Values.database.db.name }}
-  DB_PASS: {{ .Values.database.db.password }}
+  DB_HOST: {{ .Release.Name }}-database-primary
+  DB_NAME: {{ .Values.database.auth.database }}
+  DB_PASS: {{ .Values.database.auth.password }}
   DB_PREFIX: {{ .Values.wordpress.config.db.prefix}}
-  DB_USER: {{ .Values.database.db.user }}
+  DB_USER: {{ .Values.database.auth.username }}
   LANGUAGES: {{ .Values.wordpress.site.languages }}
   DEFAULT_LANG: {{ .Values.wordpress.site.default_language }}
   WP_CONTENT_MOUNT: {{ .Values.wordpress.wp_content.mount_path }}
-- 
GitLab