[MARIADB][SO] Connect MariaDB Galera via master node

To avoid "lock" situations all clients of the mariadb-galera
cluster should use the "primary" service, which connects
to the master node.
This service is provided by the mariadb-operator.
Additionally for SO the bugfix for "local" DB configuration
is fixed.
Additionally missing readiness checks added to so-cnfm-lcm and
so-etsi-nfvo-ns-lcm to wait for the DB job to complete

Issue-ID: OOM-3261
Issue-ID: OOM-2697

Change-Id: I3d44f8b6d84d112c0271bfccebc4fa533c4e6aff
Signed-off-by: Andreas Geissler <andreas-geissler@telekom.de>
diff --git a/kubernetes/so/components/so-mariadb/Chart.yaml b/kubernetes/so/components/so-mariadb/Chart.yaml
index f66f740..cb82906 100755
--- a/kubernetes/so/components/so-mariadb/Chart.yaml
+++ b/kubernetes/so/components/so-mariadb/Chart.yaml
@@ -28,9 +28,6 @@
   - name: repositoryGenerator
     version: ~13.x-0
     repository: '@local'
-  - name: readinessCheck
-    version: ~13.x-0
-    repository: '@local'
   - name: serviceAccount
     version: ~13.x-0
     repository: '@local'
diff --git a/kubernetes/so/components/so-mariadb/templates/job.yaml b/kubernetes/so/components/so-mariadb/templates/job.yaml
index 7be44c4..0afe02a 100644
--- a/kubernetes/so/components/so-mariadb/templates/job.yaml
+++ b/kubernetes/so/components/so-mariadb/templates/job.yaml
@@ -101,7 +101,21 @@
         release: {{ include "common.release" . }}
       name: {{ include "common.name" . }}
     spec:
-      initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
+      initContainers:
+      - name: {{ include "common.name" . }}-readiness
+        command:
+        - /app/ready.py
+        args:
+        - --app-name
+        - {{ include "common.mariadbAppName" . }}
+        env:
+        - name: NAMESPACE
+          valueFrom:
+            fieldRef:
+              apiVersion: v1
+              fieldPath: metadata.namespace
+        image: {{ include "repositoryGenerator.image.readiness" . }}
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
       containers:
       - name: {{ include "common.name" . }}-config
         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
diff --git a/kubernetes/so/components/so-mariadb/values.yaml b/kubernetes/so/components/so-mariadb/values.yaml
index 4aa3229..8b29e62 100755
--- a/kubernetes/so/components/so-mariadb/values.yaml
+++ b/kubernetes/so/components/so-mariadb/values.yaml
@@ -25,7 +25,9 @@
   readinessImage: onap/oom/readiness:5.0.1
   ubuntuInitRepository: docker.io
   mariadbGalera:
-    nameOverride: &mariadbName mariadb-galera
+    # flag to enable the DB creation via mariadb-operator
+    useOperator: true
+    nameOverride: mariadb-galera
     service: mariadb-galera
     servicePort: "3306"
   migration:
@@ -35,11 +37,6 @@
     dbUser: root
     dbPassword: secretpassword
 
-readinessCheck:
-  wait_for:
-    apps:
-      - *mariadbName
-
 #################################################################
 # Secrets metaconfig
 #################################################################
@@ -106,6 +103,15 @@
 pullPolicy: Always
 ubuntuInitImage: oomk8s/ubuntu-init:2.0.0
 
+# Local mariadb galera instance default name
+mariadb-galera:
+  nameOverride: so-mariadb-galera
+  service:
+    internalPort: 3306
+  mariadbOperator:
+    galera:
+      enabled: false
+
 # db config
 db:
   rootPassword: secretpassword