[MODELING]Mysql DB migrate to MariaDB Galera Cluster 17/111017/16
authordengyh <dengyuanhong@chinamobile.com>
Tue, 1 Sep 2020 00:53:59 +0000 (08:53 +0800)
committerYuanhong Deng <dengyuanhong@chinamobile.com>
Wed, 9 Sep 2020 11:58:18 +0000 (11:58 +0000)
Issue-ID: MODELING-412
Change-Id: I7d42912a9cc1f200cc1ce8916991e6e3ab5e010b
Signed-off-by: dengyh <dengyuanhong@chinamobile.com>
kubernetes/modeling/charts/modeling-etsicatalog/requirements.yaml
kubernetes/modeling/charts/modeling-etsicatalog/templates/deployment.yaml
kubernetes/modeling/charts/modeling-etsicatalog/templates/service.yaml
kubernetes/modeling/charts/modeling-etsicatalog/values.yaml

index 7fdc969..7d89fef 100644 (file)
@@ -19,3 +19,11 @@ dependencies:
   - name: mariadb-galera
     version: ~6.x-0
     repository: '@local'
+    condition: global.mariadbGalera.localCluster
+  - name: mariadb-init
+    version: ~6.x-0
+    repository: '@local'
+    condition: not global.mariadbGalera.localCluster
+  - name: readinessCheck
+    version: ~6.x-0
+    repository: '@local'
index 91fa483..014013a 100644 (file)
@@ -39,8 +39,8 @@ spec:
       - command:
         - /app/ready.py
         args:
-        - --container-name
-        - modeling-mariadb
+        - -j
+        - "{{ include "common.release" . }}-{{ include "common.name" . }}-config-job"
         env:
         - name: NAMESPACE
           valueFrom:
@@ -49,7 +49,8 @@ spec:
               fieldPath: metadata.namespace
         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        name: {{ include "common.name" . }}-readiness
+        name: {{ include "common.name" . }}-job-readiness
+      {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for.msb ) | indent 6 | trim }}
       - command:
         - /bin/sh
         - -c
@@ -62,11 +63,6 @@ spec:
           mountPath: /service/modeling/etsicatalog/static
       containers:
         - name: {{ include "common.name" . }}
-          command:
-            - bash
-          args:
-            - -c
-            - 'MYSQL_AUTH=root:${MYSQL_ROOT_PASSWORD} ./docker-entrypoint.sh'
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           ports:
@@ -87,15 +83,19 @@ spec:
             periodSeconds: {{ .Values.readiness.periodSeconds }}
           env:
           - name: MSB_PROTO
-            value: "{{ .Values.global.config.msbProtocol }}"
+            value: "{{ .Values.config.msbProtocol }}"
           - name: SSL_ENABLED
-            value: "{{ .Values.global.config.ssl_enabled }}"
+            value: "{{ .Values.config.ssl_enabled }}"
           - name: MSB_ADDR
-            value: "{{ .Values.global.config.msbServiceName }}:{{ .Values.global.config.msbPort }}"
-          - name: MYSQL_ADDR
-            value: {{ (index .Values "mariadb-galera" "service" "name") }}:{{ (index .Values "mariadb-galera" "service" "internalPort") }}
-          - name: MYSQL_ROOT_PASSWORD
-            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-pass" "key" "password") | indent 12}}
+            value: "{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPort }}"
+          - name: DB_IP
+            value: "{{ include "common.mariadbService" . }}"
+          - name: DB_PORT
+            value: "{{ include "common.mariadbPort" . }}"
+          - name: DB_USER
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "login") | indent 12 }}
+          - name: DB_PASSWD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "password") | indent 12 }}
           volumeMounts:
           - name: {{ include "common.fullname" . }}-etsicatalog
             mountPath: /service/modeling/etsicatalog/static
index 61aefa5..4dbace3 100644 (file)
@@ -30,7 +30,7 @@ metadata:
           "url": "/api/parser/v1",
           "protocol": "REST",
           "port": "{{.Values.service.externalPort}}",
-          "enable_ssl": {{ .Values.global.config.ssl_enabled }},
+          "enable_ssl": {{ .Values.config.ssl_enabled }},
           "visualRange":"1"
       },
       {
@@ -39,7 +39,7 @@ metadata:
           "url": "/api/catalog/v1",
           "protocol": "REST",
           "port": "{{.Values.service.externalPort}}",
-          "enable_ssl": {{ .Values.global.config.ssl_enabled }},
+          "enable_ssl": {{ .Values.config.ssl_enabled }},
           "visualRange":"1"
       },
          {
@@ -48,7 +48,7 @@ metadata:
           "url": "/api/nsd/v1",
           "protocol": "REST",
           "port": "{{.Values.service.externalPort}}",
-          "enable_ssl": {{ .Values.global.config.ssl_enabled }},
+          "enable_ssl": {{ .Values.config.ssl_enabled }},
           "visualRange":"1"
       },
          {
@@ -57,7 +57,7 @@ metadata:
           "url": "/api/vnfpkgm/v1",
           "protocol": "REST",
           "port": "{{.Values.service.externalPort}}",
-          "enable_ssl": {{ .Values.global.config.ssl_enabled }},
+          "enable_ssl": {{ .Values.config.ssl_enabled }},
           "visualRange":"1"
       }
       ]'
index d4719da..5926584 100644 (file)
@@ -21,29 +21,43 @@ global:
   loggingRepository: docker.elastic.co
   loggingImage: beats/filebeat:5.5.0
 
-  config:
-    ssl_enabled: false
-    msbProtocol: https
-    msbServiceName: msb-iag
-    msbPort: 443
-
   persistence:
     mountPath: /dockerdata-nfs
 
+  mariadbGalera:
+    #This flag allows Modeling to instantiate its own mariadb-galera cluster
+    localCluster: false
+    service: mariadb-galera
+    internalPort: 3306
+    nameOverride: mariadb-galera
+
+readinessCheck:
+  wait_for:
+    msb:
+      name: msb
+      containers:
+          - msb-iag
+
 #################################################################
 # Secrets metaconfig
 #################################################################
 secrets:
-  - uid: "db-root-pass"
-    externalSecret: '{{- include "common.mariadb.secret.rootPassSecretName" (dict "dot" . "chartName" (index .Values "mariadb-galera" "nameOverride")) }}'
-    type: password
+  - uid: modeling-db-secret
+    name: &dbSecretName '{{ include "common.release" . }}-modeling-db-secret'
+    type: basicAuth
+    externalSecret: '{{ tpl (default "" .Values.config.db.userCredentialsExternalSecret) . }}'
+    login: '{{ .Values.config.db.userName }}'
+    password: '{{ .Values.config.db.userPassword }}'
 
 #################################################################
 # Dependencies configuration
 #################################################################
 
 mariadb-galera:
-  nameOverride: modeling-mariadb
+  config: &mariadbConfig
+    userCredentialsExternalSecret: *dbSecretName
+    mysqlDatabase: etsicatalog
+  nameOverride: modeling-db
   service:
     name: modeling-db
     portName: modeling-db
@@ -54,14 +68,31 @@ mariadb-galera:
     enabled: true
   disableNfsProvisioner: true
 
+mariadb-init:
+  config: *mariadbConfig
+  # nameOverride should be the same with common.name
+  nameOverride: modeling-etsicatalog
+
 #################################################################
 # Application configuration defaults.
 #################################################################
+config:
+  #application configuration about  msb
+  ssl_enabled: false
+  msbProtocol: https
+  msbServiceName: msb-iag
+  msbPort: 443
+  #application configuration user password about mariadb
+  db:
+    userName: etsicatalog
+    # userPassword: password
+    # userCredentialsExternalSecret: some-secret
+
 # application image
 flavor: small
 
 repository: nexus3.onap.org:10001
-image: onap/modeling/etsicatalog:1.0.6
+image: onap/modeling/etsicatalog:1.0.7
 initImage: busybox:latest
 pullPolicy: Always