From 829f11c4192d6306cfaa579b7d879c0275b6d4c2 Mon Sep 17 00:00:00 2001 From: Andreas Geissler Date: Fri, 12 Jan 2024 12:19:03 +0100 Subject: [PATCH] [MARIADB] Provide S3 Backup for MariaDB instances Using the mariadb-operator version 0.24.0 a backup to S3 storages is supported and implemented in the templates and mariadb chart Add a missing mariadbOperator config for mariadb-init Issue-ID: OOM-3264 Change-Id: I065053832c226740b2a3b64b065cecc599f28296 Signed-off-by: Andreas Geissler --- .../oom_infra_deployment_requirements.rst | 5 ++- kubernetes/common/common/Chart.yaml | 2 +- kubernetes/common/common/templates/_mariadb.tpl | 44 +++++++++++----------- kubernetes/common/mariadb-galera/Chart.yaml | 2 +- kubernetes/common/mariadb-galera/values.yaml | 30 ++++++++++++++- kubernetes/common/mariadb-init/values.yaml | 3 ++ 6 files changed, 60 insertions(+), 26 deletions(-) diff --git a/docs/sections/guides/infra_guides/oom_infra_deployment_requirements.rst b/docs/sections/guides/infra_guides/oom_infra_deployment_requirements.rst index 3d824c7171..4eefdafbf3 100644 --- a/docs/sections/guides/infra_guides/oom_infra_deployment_requirements.rst +++ b/docs/sections/guides/infra_guides/oom_infra_deployment_requirements.rst @@ -48,9 +48,9 @@ The versions of software that are supported and tested by OOM are as follows: ============== =========== ======= ======== ======== ============= ======== Release Kubernetes Helm kubectl Docker Cert-Manager Strimzi ============== =========== ======= ======== ======== ============= ======== - Kohn 1.23.8 3.8.2 1.23.8 20.10.x 1.8.0 0.32.0 London 1.23.8 3.8.2 1.23.x 20.10.x 1.12.2 0.35.0 Montreal 1.27.5 3.12.3 1.27.x 20.10.x 1.13.2 0.36.1 + New Delhi 1.27.5 3.12.3 1.27.x 20.10.x 1.13.2 0.36.3 ============== =========== ======= ======== ======== ============= ======== .. table:: OOM Software Requirements (production) @@ -60,6 +60,7 @@ The versions of software that are supported and tested by OOM are as follows: ============== ====== ============ ============== London 1.17.2 v0.6.2 19.0.3-legacy Montreal 1.19.3 v1.0.0 19.0.3-legacy + New Delhi 1.19.3 v1.0.0 19.0.3-legacy ============== ====== ============ ============== .. table:: OOM Software Requirements (optional) @@ -67,7 +68,7 @@ The versions of software that are supported and tested by OOM are as follows: ============== ================= ========== ================= Release Prometheus Stack K8ssandra MariaDB-Operator ============== ================= ========== ================= - Kohn 35.x London 45.x 1.6.1 Montreal 45.x 1.10.2 0.23.1 + New Delhi 45.x 1.11.0 0.24.0 ============== ================= ========== ================= diff --git a/kubernetes/common/common/Chart.yaml b/kubernetes/common/common/Chart.yaml index 4025924f80..129454681e 100644 --- a/kubernetes/common/common/Chart.yaml +++ b/kubernetes/common/common/Chart.yaml @@ -16,4 +16,4 @@ apiVersion: v2 description: Common templates for inclusion in other charts name: common -version: 13.0.2 +version: 13.0.3 diff --git a/kubernetes/common/common/templates/_mariadb.tpl b/kubernetes/common/common/templates/_mariadb.tpl index a2d4117e5c..a0dd49d750 100644 --- a/kubernetes/common/common/templates/_mariadb.tpl +++ b/kubernetes/common/common/templates/_mariadb.tpl @@ -80,7 +80,7 @@ {{- index .Values "mariadb-galera" "nameOverride" -}} {{- end }} {{- else -}} - {{- if and .Values.global.mariadbGalera.useOperator }} + {{- if .Values.global.mariadbGalera.useOperator }} {{- printf "%s-primary" (.Values.global.mariadbGalera.service) }} {{- else }} {{- .Values.global.mariadbGalera.service -}} @@ -194,26 +194,37 @@ spec: {{- define "common.mariadbOpBackup" -}} {{- $dot := default . .dot -}} {{- $dbinst := include "common.name" $dot -}} +{{- $name := default $dbinst $dot.Values.backup.nameOverride -}} +--- +apiVersion: mariadb.mmontes.io/v1alpha1 kind: Backup metadata: - name: backup-scheduled + name: {{ $name }} spec: mariaDbRef: name: {{ $dbinst }} schedule: - cron: "*/1 * * * *" + cron: {{ $dot.Values.backup.cron }} suspend: false - maxRetentionDays: 30 + maxRetention: {{ $dot.Values.backup.maxRetention }} storage: + {{- if eq $dot.Values.backup.storageType "PVC" }} persistentVolumeClaim: resources: requests: - storage: 100Mi - {{- if .Values.mariadbOperator.storageClassName }} - storageClassName: {{ .Values.mariadbOperator.storageClassName }} + storage: {{ $dot.Values.backup.persistence.size }} + {{- if $dot.Values.mariadbOperator.storageClassName }} + storageClassName: {{ $dot.Values.mariadbOperator.storageClassName }} {{- end }} accessModes: - - ReadWriteOnce + - {{ $dot.Values.backup.persistence.accessMode }} + {{- end }} + {{- if eq $dot.Values.backup.storageType "S3" }} + s3: {{- include "common.tplValue" ( dict "value" .Values.backup.s3 "context" $) | nindent 6 }} + {{- end }} + {{- if eq $dot.Values.backup.storageType "volume" }} + volume: {{- include "common.tplValue" ( dict "value" .Values.backup.volume "context" $) | nindent 6 }} + {{- end }} resources: requests: cpu: 100m @@ -308,6 +319,10 @@ spec: initialDelaySeconds: 20 periodSeconds: 10 timeoutSeconds: 5 + {{- if default false .Values.global.metrics.enabled }} + metrics: + enabled: true + {{- end }} affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -320,19 +335,6 @@ spec: maxUnavailable: 50% updateStrategy: type: RollingUpdate - #myCnf: | - # [mysqld] - # bind-address=0.0.0.0 - # default_storage_engine=InnoDB - # binlog_format=row - # innodb_autoinc_lock_mode=2 - # max_allowed_packet=256M - # lower_case_table_names = 1 - - # ## Character set - # collation_server=utf8_unicode_ci - # init_connect='SET NAMES utf8' - # character_set_server=utf8 myCnfConfigMapKeyRef: key: my.cnf diff --git a/kubernetes/common/mariadb-galera/Chart.yaml b/kubernetes/common/mariadb-galera/Chart.yaml index 71ff421d7b..470e64b5f1 100644 --- a/kubernetes/common/mariadb-galera/Chart.yaml +++ b/kubernetes/common/mariadb-galera/Chart.yaml @@ -18,7 +18,7 @@ apiVersion: v2 description: Chart for MariaDB Galera cluster name: mariadb-galera -version: 13.0.1 +version: 13.1.0 keywords: - mariadb - mysql diff --git a/kubernetes/common/mariadb-galera/values.yaml b/kubernetes/common/mariadb-galera/values.yaml index 991c635749..be7ad8ef07 100644 --- a/kubernetes/common/mariadb-galera/values.yaml +++ b/kubernetes/common/mariadb-galera/values.yaml @@ -267,8 +267,16 @@ galera: ## For this reason the db data pvc needs to have accessMode: ReadWriteMany. backup: enabled: false + # used in the mariadb-operator to override the backup name (default is DBName) + # nameOverride: + # defines the backup job execution period cron: "00 00 * * *" + # used by mariadb-operator to set the max retention time + maxRetention: 720h retentionPeriod: 3 + # used by mariadb-operator to set the backup storage type (PVC, S3, volume) + storageType: PVC + # configuration used for PVC backup storage persistence: ## If true, use a Persistent Volume Claim, If false, use emptyDir ## @@ -297,7 +305,27 @@ backup: ## Persistent Volume size ## size: 2Gi - + # requires mariadb-operator v0.24.0 + # configuration used for S3 backup storage + # see: https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/BACKUP.md + s3: + bucket: backups + endpoint: minio.minio.svc.cluster.local:9000 + #region: us-east-1 + accessKeyIdSecretKeyRef: + name: minio + key: access-key-id + secretAccessKeySecretKeyRef: + name: minio + key: secret-access-key + tls: + enabled: false + caSecretKeyRef: + name: minio-ca + key: ca.crt + # configuration used for kubernetes volumes as backup storage + # see: https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/BACKUP.md + volume: {} readinessCheck: wait_for: diff --git a/kubernetes/common/mariadb-init/values.yaml b/kubernetes/common/mariadb-init/values.yaml index 2d5de97e7c..fb2e202fd0 100644 --- a/kubernetes/common/mariadb-init/values.yaml +++ b/kubernetes/common/mariadb-init/values.yaml @@ -81,6 +81,9 @@ mariadb-galera: service: internalPort: 3306 nameOverride: mariadb-galera + mariadbOperator: + galera: + enabled: false config: userPassword: Ci@shsOd3pky1Vji -- 2.16.6