feat(mariadb): Add template support for existing secrets

Signed-off-by: Axel Lender <lender@b1-systems.de>
This commit is contained in:
Axel Lender
2025-12-03 20:47:03 +01:00
parent 3890df064e
commit c656786bc0
3 changed files with 52 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ This document covers how to utilise existing secrets and special requirements. T
* [Components](#components) * [Components](#components)
* [Cassandra](#cassandra) * [Cassandra](#cassandra)
* [Keycloak](#keycloak) * [Keycloak](#keycloak)
* [MariaDB](#mariadb)
* [MinIO](#minio) * [MinIO](#minio)
* [Notes](#notes) * [Notes](#notes)
* [OpenProject](#openproject) * [OpenProject](#openproject)
@@ -120,6 +121,46 @@ Values taken from those existing secrets will supersede secret values that are a
clientId: "yourSecretValueHere" clientId: "yourSecretValueHere"
clientSecret: "yourSecretValueHere" clientSecret: "yourSecretValueHere"
``` ```
## MariaDB
When initialising databases, users and credentials the Chart expects `.sql` files inside the secret to mount and feed them to the database client.
The expected format for the databases is as follows:
```yaml
stringData:
init-db-open-xchange.sql: |
CREATE DATABASE IF NOT EXISTS openxchange_dummy;
GRANT ALL PRIVILEGES ON openxchange_dummy.* TO "openxchange_user"@"%";
FLUSH PRIVILEGES;
init-db-nextcloud.sql: |
CREATE DATABASE IF NOT EXISTS nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO "nextcloud_user"@"%";
FLUSH PRIVILEGES;
init-db-xwiki.sql: |
CREATE DATABASE IF NOT EXISTS xwiki;
GRANT ALL PRIVILEGES ON xwiki.* TO "xwiki_user"@"%";
FLUSH PRIVILEGES;
```
For the user and credentials the following format is expected:
```yaml
stringData:
init-user-open-xchange.sql: |
CREATE USER IF NOT EXISTS "openxchange_user"@"%" IDENTIFIED BY {{ .Values.secrets.mariadb.openxchangeUser | quote }};
ALTER USER "openxchange_user"@"%" WITH MAX_USER_CONNECTIONS 100;
ALTER USER "openxchange_user"@"%" IDENTIFIED BY {{ .Values.secrets.mariadb.openxchangeUser | quote }};
init-user-nextcloud.sql: |
CREATE USER IF NOT EXISTS "nextcloud_user"@"%" IDENTIFIED BY {{ .Values.secrets.mariadb.nextcloudUser | quote }};
ALTER USER "nextcloud_user"@"%" WITH MAX_USER_CONNECTIONS 100;
ALTER USER "nextcloud_user"@"%" IDENTIFIED BY {{ .Values.secrets.mariadb.nextcloudUser | quote }};
init-user-xwiki.sql: |
CREATE USER IF NOT EXISTS "xwiki_user"@"%" IDENTIFIED BY {{ .Values.secrets.mariadb.xwikiUser | quote }};
ALTER USER "xwiki_user"@"%" WITH MAX_USER_CONNECTIONS 100;
ALTER USER "xwiki_user"@"%" IDENTIFIED BY {{ .Values.secrets.mariadb.xwikiUser | quote }};
```
## MinIO ## MinIO

View File

@@ -53,6 +53,7 @@ job:
password: {{ .Values.secrets.mariadb.xwikiUser | quote }} password: {{ .Values.secrets.mariadb.xwikiUser | quote }}
connectionLimit: {{ .Values.databases.xwiki.connectionLimit | default .Values.databases.defaults.userConnectionLimit }} connectionLimit: {{ .Values.databases.xwiki.connectionLimit | default .Values.databases.defaults.userConnectionLimit }}
{{ end }} {{ end }}
usersExistingSecret: {{ .Values.existingSecrets.mariadb.users | quote }}
databases: databases:
# OX uses root user and auto automanages the database, we add a dummy user and create a dummy/empty database. # OX uses root user and auto automanages the database, we add a dummy user and create a dummy/empty database.
- name: "openxchange_dummy" - name: "openxchange_dummy"
@@ -66,10 +67,14 @@ job:
- name: {{ .Values.databases.xwiki.name | quote }} - name: {{ .Values.databases.xwiki.name | quote }}
user: "xwiki_user" user: "xwiki_user"
{{ end }} {{ end }}
databasesExistingSecret: {{ .Values.existingSecrets.mariadb.databases | quote }}
mariadb: mariadb:
rootPassword: rootPassword:
value: {{ .Values.secrets.mariadb.rootPassword | quote }} value: {{ .Values.secrets.mariadb.rootPassword | quote }}
existingSecret:
name: {{ .Values.existingSecrets.mariadb.rootPassword.name | quote }}
key: {{ .Values.existingSecrets.mariadb.rootPassword.key | quote }}
persistence: persistence:
size: {{ .Values.persistence.storages.mariadb.size | quote }} size: {{ .Values.persistence.storages.mariadb.size | quote }}

View File

@@ -131,6 +131,12 @@ existingSecrets:
clients: clients:
name: ~ name: ~
key: ~ key: ~
mariadb:
rootPassword:
name: ~
key: ~
databases: ~
users: ~
minio: minio:
existingSecret: ~ existingSecret: ~
rootUserSecretKey: ~ rootUserSecretKey: ~