Merge "[MARIADB] Update mariadb-operator and templates to 0.27.0"
diff --git a/kubernetes/common/common/Chart.yaml b/kubernetes/common/common/Chart.yaml
index bb9e8a2..ffcda67 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.1.0
+version: 13.2.0
diff --git a/kubernetes/common/common/templates/_mariadb.tpl b/kubernetes/common/common/templates/_mariadb.tpl
index caf2fd1..41259b3 100644
--- a/kubernetes/common/common/templates/_mariadb.tpl
+++ b/kubernetes/common/common/templates/_mariadb.tpl
@@ -118,14 +118,14 @@
 {{- end -}}
 
 {{/*
-  Create MariDB Database via mariadb-operator
+  Create MariaDB Database via mariadb-operator
 */}}
 {{- define "common.mariadbOpDatabase" -}}
 {{- $dot := default . .dot -}}
 {{- $dbname := (required "'dbame' param, is required." .dbname) -}}
 {{- $dbinst := (required "'dbinst' param, is required." .dbinst) -}}
 ---
-apiVersion: mariadb.mmontes.io/v1alpha1
+apiVersion: k8s.mariadb.com/v1alpha1
 kind: Database
 metadata:
   name: {{ $dbinst }}-{{ $dbname }}
@@ -147,7 +147,7 @@
 {{- $dbinst := (required "'dbinst' param, is required." .dbinst) -}}
 {{- $dbsecret := (required "'dbsecret' param, is required." .dbsecret) -}}
 ---
-apiVersion: mariadb.mmontes.io/v1alpha1
+apiVersion: k8s.mariadb.com/v1alpha1
 kind: User
 metadata:
   name: {{ $dbinst }}-{{ $dbuser }}
@@ -155,6 +155,7 @@
   name: {{ $dbuser }}
   mariaDbRef:
     name: {{ $dbinst }}
+    waitForIt: true
   passwordSecretKeyRef:
     name: {{ $dbsecret }}
     key: password
@@ -172,13 +173,14 @@
 {{- $dbname := (required "'dbame' param, is required." .dbname) -}}
 {{- $dbinst := (required "'dbinst' param, is required." .dbinst) -}}
 ---
-apiVersion: mariadb.mmontes.io/v1alpha1
+apiVersion: k8s.mariadb.com/v1alpha1
 kind: Grant
 metadata:
   name: {{ $dbuser }}-{{ $dbname }}-{{ $dbinst }}
 spec:
   mariaDbRef:
     name: {{ $dbinst }}
+    waitForIt: true
   privileges:
     - "ALL"
   database: {{ $dbname }}
@@ -196,13 +198,19 @@
 {{- $dbinst := include "common.name" $dot -}}
 {{- $name := default $dbinst $dot.Values.backup.nameOverride -}}
 ---
-apiVersion: mariadb.mmontes.io/v1alpha1
+apiVersion: k8s.mariadb.com/v1alpha1
 kind: Backup
 metadata:
   name: {{ $name }}
 spec:
+  inheritMetadata:
+    labels:
+      sidecar.istio.io/inject: 'false'
+  backoffLimit: 5
+  logLevel: info
   mariaDbRef:
     name: {{ $dbinst }}
+    waitForIt: true
   schedule:
     cron: {{ $dot.Values.backup.cron }}
     suspend: false
@@ -244,7 +252,7 @@
 {{- $dbrootsecret := tpl (default (include "common.mariadb.secret.rootPassSecretName" (dict "dot" $dot "chartName" "")) $dot.Values.rootUser.externalSecret) $dot -}}
 {{- $dbusersecret := tpl (default (include "common.mariadb.secret.userCredentialsSecretName" (dict "dot" $dot "chartName" "")) $dot.Values.db.externalSecret) $dot -}}
 ---
-apiVersion: mariadb.mmontes.io/v1alpha1
+apiVersion: k8s.mariadb.com/v1alpha1
 kind: MariaDB
 metadata:
   name: {{ $dbinst }}
@@ -258,6 +266,9 @@
     annotations: {{ toYaml .Values.podAnnotations | nindent 6 }}
     {{- end }}
     labels:
+      # temporarily test mariaDB without sidecar (fix initial Job, Backup and Metrics)
+      # will be obsolete with "native-sidecars" feature in K8S and Istio
+      sidecar.istio.io/inject: "false"
       app: {{ $dbinst }}
       version: {{ .Values.mariadbOperator.appVersion }}
   rootPasswordSecretKeyRef:
@@ -281,24 +292,30 @@
         enabled: true
         authDelegatorRoleName: {{ $dbinst }}-auth
       gracefulShutdownTimeout: 5s
+    primary:
+      automaticFailover: true
+      podIndex: 0
     recovery:
       enabled: true
-      clusterHealthyTimeout: 5m0s
+      clusterHealthyTimeout: 30s
       clusterBootstrapTimeout: 10m0s
-      podRecoveryTimeout: 5m0s
-      podSyncTimeout: 10m0s
+      minClusterSize: 50%
+      podRecoveryTimeout: 3m0s
+      podSyncTimeout: 3m0s
     initContainer:
       image: {{ include "repositoryGenerator.githubContainerRegistry" . }}/{{ $dot.Values.mariadbOperator.galera.initImage }}:{{ $dot.Values.mariadbOperator.galera.initVersion }}
       imagePullPolicy: IfNotPresent
-    volumeClaimTemplate:
-      {{- if .Values.mariadbOperator.storageClassName }}
-      storageClassName: {{ .Values.mariadbOperator.storageClassName }}
-      {{- end }}
-      resources:
-        requests:
-          storage: 50Mi
-      accessModes:
-        - ReadWriteOnce
+    config:
+      reuseStorageVolume: false
+      volumeClaimTemplate:
+        {{- if .Values.mariadbOperator.persistence.storageClassName }}
+        storageClassName: {{ .Values.mariadbOperator.persistence.storageClassName }}
+        {{- end }}
+        resources:
+          requests:
+            storage: 50Mi
+        accessModes:
+          - ReadWriteOnce
   {{- end }}
   livenessProbe:
     exec:
@@ -318,7 +335,7 @@
     initialDelaySeconds: 20
     periodSeconds: 10
     timeoutSeconds: 5
-  {{- if default false .Values.global.metrics.enabled }}
+  {{- if default false $dot.Values.global.metrics.enabled }}
   metrics:
     enabled: true
   {{- end }}
@@ -327,7 +344,7 @@
       requiredDuringSchedulingIgnoredDuringExecution:
         - topologyKey: kubernetes.io/hostname
   tolerations:
-    - key: mariadb.mmontes.io/ha
+    - key: k8s.mariadb.com/ha
       operator: Exists
       effect: NoSchedule
   podDisruptionBudget:
@@ -339,15 +356,11 @@
     key: my.cnf
     name: {{ printf "%s-configuration" (include "common.fullname" $dot) }}
   resources: {{ include "common.resources" . | nindent 4 }}
-  volumeClaimTemplate:
-    {{- if $dot.Values.mariadbOperator.storageClassName }}
-    storageClassName: {{ $dot.Values.mariadbOperator.storageClassName }}
+  storage:
+    {{- if $dot.Values.mariadbOperator.persistence.storageClassName }}
+    storageClassName: {{ $dot.Values.mariadbOperator.persistence.storageClassName }}
     {{- end }}
-    resources:
-      requests:
-        storage: {{ $dot.Values.mariadbOperator.persistence.size | quote }}
-    accessModes:
-      - ReadWriteOnce
+    size: {{ $dot.Values.mariadbOperator.persistence.size | quote }}
 {{-  if $dot.Values.db.user }}
 {{ include "common.mariadbOpUser" (dict "dot" . "dbuser" $dot.Values.db.user "dbinst" $dbinst "dbsecret" $dbusersecret) }}
 {{-  end }}
diff --git a/kubernetes/common/mariadb-galera/Chart.yaml b/kubernetes/common/mariadb-galera/Chart.yaml
index 470e64b..c5bb0aa 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.1.0
+version: 13.2.0
 keywords:
   - mariadb
   - mysql
diff --git a/kubernetes/common/mariadb-galera/values.yaml b/kubernetes/common/mariadb-galera/values.yaml
index 9a27e60..3d9725c 100644
--- a/kubernetes/common/mariadb-galera/values.yaml
+++ b/kubernetes/common/mariadb-galera/values.yaml
@@ -56,16 +56,16 @@
 
 mariadbOperator:
   image: mariadb
-  appVersion: 11.1.2
+  appVersion: 11.2.2
   persistence:
     #storageClassName: default
     size: 3Gi
   galera:
     enabled: true
-    agentImage: mariadb-operator/agent
-    agentVersion: v0.0.3
-    initImage: mariadb-operator/init
-    initVersion: v0.0.6
+    agentImage: mariadb-operator/mariadb-operator
+    agentVersion: v0.0.27
+    initImage: mariadb-operator/mariadb-operator
+    initVersion: v0.0.27
 
 ## String to partially override common.names.fullname template (will maintain the release name)
 ##
@@ -99,7 +99,7 @@
   #  sidecar.istio.io/inject: "false"
   traffic.sidecar.istio.io/excludeInboundPorts: "4444,4567,4568"
   traffic.sidecar.istio.io/includeInboundPorts: '*'
-  traffic.sidecar.istio.io/excludeOutboundPorts: "4444,4567,4568"
+  traffic.sidecar.istio.io/excludeOutboundPorts: "4444,4567,4568,443"
 
 mariadbOpConfiguration: |-
   [mysqld]