Merge "Vid Template alignment."
authorMandeep Khinda <Mandeep.Khinda@amdocs.com>
Tue, 18 Sep 2018 15:02:03 +0000 (15:02 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 18 Sep 2018 15:02:03 +0000 (15:02 +0000)
18 files changed:
kubernetes/vid/charts/vid-mariadb-galera/Chart.yaml [moved from kubernetes/vid/charts/vid-galera/Chart.yaml with 87% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/NOTES.txt [moved from kubernetes/vid/charts/vid-galera/templates/NOTES.txt with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/configmap.yaml [moved from kubernetes/vid/charts/vid-galera/templates/configmap.yaml with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/pv.yaml [moved from kubernetes/vid/charts/vid-galera/templates/pv.yaml with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/pvc.yaml [moved from kubernetes/vid/charts/vid-galera/templates/pvc.yaml with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/secrets.yaml [moved from kubernetes/vid/charts/vid-galera/templates/secrets.yaml with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/service.yaml [moved from kubernetes/vid/charts/vid-galera/templates/service.yaml with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/templates/statefulset.yaml [moved from kubernetes/vid/charts/vid-galera/templates/statefulset.yaml with 100% similarity]
kubernetes/vid/charts/vid-mariadb-galera/values.yaml [moved from kubernetes/vid/charts/vid-galera/values.yaml with 99% similarity]
kubernetes/vid/resources/config/db_cmd.sh [moved from kubernetes/vid/templates/dbcmd-configmap.yaml with 57% similarity]
kubernetes/vid/resources/config/vid-pre-init.sql [new file with mode: 0644]
kubernetes/vid/templates/check-job-completion-configmap.yaml [deleted file]
kubernetes/vid/templates/cluster-ready-configmap.yaml [deleted file]
kubernetes/vid/templates/configmap.yaml
kubernetes/vid/templates/deployment.yaml
kubernetes/vid/templates/galera-sql-configmap.yaml [deleted file]
kubernetes/vid/templates/vid-galera-config-job.yaml
kubernetes/vid/values.yaml

@@ -13,9 +13,9 @@
 # limitations under the License.
 
 apiVersion: v1
-description: Chart for MariaDB Galera cluster
-name: mariadb-galera
-version: 2.0.0
+description: ONAP VID MariaDB Galera cluster
+name: vid_mariadb_galera
+version: 3.0.0
 keywords:
   - mariadb
   - mysql
@@ -126,7 +126,7 @@ resources:
     memory: 4Gi
 
 # Name for mariadb-galera cluster - should be unique accross all projects or other clusters
-nameOverride: vid-galera
+nameOverride: vid-mariadb-galera
 
 # DNS name for mariadb-galera cluster - should be unique accross all projects other clusters
 #dnsnameOverride: mariadb-galera
similarity index 57%
rename from kubernetes/vid/templates/dbcmd-configmap.yaml
rename to kubernetes/vid/resources/config/db_cmd.sh
index aa08801..95b83d4 100644 (file)
@@ -1,4 +1,5 @@
-# Copyright © 2018 Amdocs, Bell Canada
+#!/bin/sh
+# Copyright © 2018 AT&T
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ include "common.fullname" . }}-dbcmd-configmap
-  namespace: {{ include "common.namespace" . }}
-data:
- db_cmd.sh : |-
-   #!/bin/sh
-   #mysql -uroot -p${MYSQL_ROOT_PASSWORD} -h${MYSQL_HOST} -P3306 < /db-config/vid-pre-init.sql
-   mysql -uvidadmin -p${MYSQL_PASSWORD} -h${MYSQL_HOST} -P3306 < /db-config/vid-pre-init.sql
-
+echo "Going to run mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_HOST} -P${MYSQL_PORT} ..."
+mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_HOST} -P${MYSQL_PORT} < /db-config/vid-pre-init.sql
+if [ $? -ne 0 ];then
+        echo "ERROR: Failed to run ${cmd} vid-pre-init.sql"
+        exit 1
+else
+        echo "INFO: Database initialized successfully"
+fi
diff --git a/kubernetes/vid/resources/config/vid-pre-init.sql b/kubernetes/vid/resources/config/vid-pre-init.sql
new file mode 100644 (file)
index 0000000..2dbbbcc
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+# Copyright © 2018 AT&T
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/
+
+CREATE TABLE IF NOT EXISTS `vid_openecomp_epsdk`.`schema_info` (
+`SCHEMA_ID` VARCHAR(25) NOT NULL,
+`SCHEMA_DESC` VARCHAR(75) NOT NULL,
+`DATASOURCE_TYPE` VARCHAR(100) NULL DEFAULT NULL,
+`CONNECTION_URL` VARCHAR(200) NOT NULL,
+`USER_NAME` VARCHAR(45) NOT NULL,
+`PASSWORD` VARCHAR(45) NULL DEFAULT NULL,
+`DRIVER_CLASS` VARCHAR(100) NOT NULL,
+`MIN_POOL_SIZE` INT(11) NOT NULL,
+`MAX_POOL_SIZE` INT(11) NOT NULL,
+`IDLE_CONNECTION_TEST_PERIOD` INT(11) NOT NULL)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8;
\ No newline at end of file
diff --git a/kubernetes/vid/templates/check-job-completion-configmap.yaml b/kubernetes/vid/templates/check-job-completion-configmap.yaml
deleted file mode 100644 (file)
index 270615a..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-# Copyright © 2018 Amdocs, Bell Canada
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ include "common.fullname" . }}-check-job-completion
-  namespace: {{ include "common.namespace" . }}
-data:
-  vid_check_job_completion.py: |
-    #!/usr/bin/python
-    from __future__ import print_function
-    import time, argparse, logging, sys, os
-    import kubernetes.client
-    from kubernetes import client, config
-    from pprint import pprint
-
-    #extract env variables.
-    namespace = os.environ['NAMESPACE']
-    cert = os.environ['CERT']
-    host = os.environ['KUBERNETES_SERVICE_HOST']
-    token_path = os.environ['TOKEN']
-
-    with open(token_path, 'r') as token_file:
-        token = token_file.read().replace('\n', '')
-
-    client.configuration.api_key['authorization'] = token
-    client.configuration.api_key_prefix['authorization'] = 'Bearer'
-    client.configuration.host = "https://" + str(host)
-    client.configuration.ssl_ca_cert = cert
-
-    api_instance = client.BatchV1Api()
-
-    #setup logging
-    log = logging.getLogger(__name__)
-    handler = logging.StreamHandler(sys.stdout)
-    handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
-    handler.setLevel(logging.INFO)
-    log.addHandler(handler)
-    log.setLevel(logging.INFO)
-
-
-    def is_ready(job_name):
-        log.info( "[INFO] Checking if " + job_name + "  is completed")
-        pretty = True
-        job_status = False
-
-        try:
-            api_response = api_instance.read_namespaced_job_status(job_name, namespace, pretty=pretty)
-        except Exception as e:
-          print("Exception when calling BatchV1Api->read_namespaced_job_status: %s\n" % e)
-
-        pprint(api_response)
-        if api_response.status.succeeded == 1:
-          job_status_type = api_response.status.conditions[0].type
-          if job_status_type == "Complete":
-            job_status = True
-
-        print("[DBG] jobStatus: " + unicode(job_status))
-        return job_status
-
-
-    def main(args):
-        for job_name in args:
-            timeout = time.time() + 60 * 10
-            while True:
-                ready = is_ready(job_name)
-                if ready is True :
-                    break
-                elif time.time() > timeout:
-                    log.warning( "timed out waiting for '" + job_name + "' to be ready")
-                    exit(1)
-                else:
-                    time.sleep(5)
-
-
-    if __name__ == "__main__":
-        parser = argparse.ArgumentParser(description='Process some names.')
-        parser.add_argument('--job-name', action='append', required=True, help='A container name')
-        args = parser.parse_args()
-        arg_dict = vars(args)
-
-        for arg in arg_dict.itervalues():
-            main(arg)
-
-
diff --git a/kubernetes/vid/templates/cluster-ready-configmap.yaml b/kubernetes/vid/templates/cluster-ready-configmap.yaml
deleted file mode 100644 (file)
index 86f8d91..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright © 2018 Amdocs, Bell Canada
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ include "common.fullname" . }}-cluster-ready-configmap
-  namespace: {{ include "common.namespace" . }}
-data:
- vid_ready.py : |-
-   #!/usr/bin/python
-   from kubernetes import client, config
-   import time, argparse, logging, sys, os
-
-   #extract env variables.
-   namespace = os.environ['NAMESPACE']
-   cert = os.environ['CERT']
-   host = os.environ['KUBERNETES_SERVICE_HOST']
-   token_path = os.environ['TOKEN']
-
-   with open(token_path, 'r') as token_file:
-       token = token_file.read().replace('\n', '')
-
-   client.configuration.host = "https://" + host
-   client.configuration.ssl_ca_cert = cert
-   client.configuration.api_key['authorization'] = token
-   client.configuration.api_key_prefix['authorization'] = 'Bearer'
-
-   #setup logging
-   log = logging.getLogger(__name__)
-   handler = logging.StreamHandler(sys.stdout)
-   handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
-   handler.setLevel(logging.INFO)
-   log.addHandler(handler)
-   log.setLevel(logging.INFO)
-
-
-   def is_ready(container_name):
-       log.info( "Checking if " + container_name + "  is ready")
-       # config.load_kube_config() # for local testing
-       # namespace='onap-sdc' # for local testing
-       v1 = client.CoreV1Api()
-
-       ready = False
-
-       try:
-           response = v1.list_namespaced_pod(namespace=namespace, watch=False)
-
-           for i in response.items:
-               #log.info(i.metadata.name)
-               for s in i.status.container_statuses:
-                   #log.info(s.name)
-                   if i.metadata.name == container_name:
-                       ready = s.ready
-                       if not ready:
-                           log.info( container_name + " is not ready.")
-                       else:
-                           log.info( container_name + " is ready!")
-                   else:
-                       continue
-           return ready
-       except Exception as e:
-           log.error("Exception when calling list_namespaced_pod: %s\n" % e)
-
-
-   def main(args):
-       # args are a list of container names
-       for container_name in args:
-           # 5 min, TODO: make configurable
-           timeout = time.time() + 60 * 10
-           while True:
-               ready = is_ready(container_name)
-               if ready is True:
-                   break
-               elif time.time() > timeout:
-                   log.warning( "timed out waiting for '" + container_name + "' to be ready")
-                   exit(1)
-               else:
-                   time.sleep(5)
-
-
-   if __name__ == "__main__":
-       parser = argparse.ArgumentParser(description='Process some names.')
-       parser.add_argument('--container-name', action='append', required=True, help='A container name')
-       args = parser.parse_args()
-       arg_dict = vars(args)
-
-       for arg in arg_dict.itervalues():
-           main(arg)
-
-
-
index f7dbf07..cae46b4 100644 (file)
@@ -27,3 +27,16 @@ metadata:
   namespace: {{ include "common.namespace" . }}
 data:
 {{ tpl (.Files.Glob "resources/config/log/filebeat/*").AsConfig . | indent 2 }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "common.fullname" . }}
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/config/*").AsConfig . | indent 2 }}
\ No newline at end of file
index 5c98b04..5cd4f38 100644 (file)
@@ -31,16 +31,9 @@ spec:
         release: {{ .Release.Name }}
     spec:
       initContainers:
-#dd775k: This container checks if the job that wait for all db instances to be up and initializes the db had finished.
-#      - command:
-#        - /bin/sh
-#        args:
-#        - "-c"
-#        - "sleep 1000000000m"
       - command:
-        - python
+        - /root/job_complete.py
         args:
-        - /tmp/vid-check-job-completion/vid_check_job_completion.py
         - --job-name
         - vid-config-galera
         env:
@@ -52,9 +45,6 @@ spec:
         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         name: {{ include "common.name" . }}-readiness
-        volumeMounts:
-        - mountPath: /tmp/vid-check-job-completion
-          name: vid-check-job-completion
       containers:
         - name: {{ include "common.name" . }}
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
@@ -163,10 +153,6 @@ spec:
         - name: vid-logback
           configMap:
             name: {{ include "common.fullname" . }}-log-configmap
-        - name: vid-check-job-completion
-          configMap:
-            name: {{ include "common.fullname" . }}-check-job-completion
       imagePullSecrets:
       - name: "{{ include "common.namespace" . }}-docker-registry-key"
 
-
diff --git a/kubernetes/vid/templates/galera-sql-configmap.yaml b/kubernetes/vid/templates/galera-sql-configmap.yaml
deleted file mode 100644 (file)
index 7f05af5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright © 2018 Amdocs, Bell Canada
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ include "common.fullname" . }}-galera-sql-configmap
-  namespace: "{{ include "common.namespace" . }}"
-data:
-  vid-pre-init.sql: |-
-   CREATE TABLE IF NOT EXISTS `vid_openecomp_epsdk`.`schema_info` (
-   `SCHEMA_ID` VARCHAR(25) NOT NULL,
-   `SCHEMA_DESC` VARCHAR(75) NOT NULL,
-   `DATASOURCE_TYPE` VARCHAR(100) NULL DEFAULT NULL,
-   `CONNECTION_URL` VARCHAR(200) NOT NULL,
-   `USER_NAME` VARCHAR(45) NOT NULL,
-   `PASSWORD` VARCHAR(45) NULL DEFAULT NULL,
-   `DRIVER_CLASS` VARCHAR(100) NOT NULL,
-   `MIN_POOL_SIZE` INT(11) NOT NULL,
-   `MAX_POOL_SIZE` INT(11) NOT NULL,
-   `IDLE_CONNECTION_TEST_PERIOD` INT(11) NOT NULL)
-    ENGINE = InnoDB
-    DEFAULT CHARACTER SET = utf8;
-
index b893dbf..2bcf647 100644 (file)
@@ -28,35 +28,34 @@ spec:
       name: vid-galera-init
     spec:
       initContainers:
-#dd775k:  This container checks that all galera instances are up before initializing it.
+#This container checks that all galera instances are up before initializing it.
       - name: vid-init-galera-readiness
         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-#        - /bin/sh
-#        args:
-#        - "-c"
-#        - "sleep 1000000000m"
         command:
-        - python
-        args:
-        - /root/vid_ready.py
+        - /root/ready.py
+{{- $fullname := include "common.fullname" . -}}
+{{- range $i,$t := until (int .Values.vid_mariadb_galera.replicaCount)}}
         - --container-name
-        - {{ include "common.fullname" . }}-mariadb-galera-0
+        - {{ $fullname }}-mariadb-galera-{{$i}}
+{{- end }}
         env:
         - name: NAMESPACE
-          value: {{ include "common.namespace" . }}
-        volumeMounts:
-        - name: init-config
-          mountPath: /root/
+          valueFrom:
+            fieldRef:
+              apiVersion: v1
+              fieldPath: metadata.namespace
       containers:
       - name: vid-config-galeradb
         image: {{ .Values.mariadb_image }}
         imagePullPolicy: "{{ .Values.pullPolicy }}"
         volumeMounts:
-        - name: vid-db-config
-          mountPath: /db-config
-        - name: dbcmd-config
-          mountPath: /dbcmd-config
+        - mountPath: /dbcmd-config/db_cmd.sh
+          name: {{ include "common.fullname" . }}-config
+          subPath: db_cmd.sh
+        - mountPath: /db-config/vid-pre-init.sql
+          name: {{ include "common.fullname" . }}-config
+          subPath: vid-pre-init.sql
         command:
         - /bin/sh
         args:
@@ -65,22 +64,20 @@ spec:
         env:
         - name: MYSQL_PASSWORD
           value: "{{ .Values.config.vidmysqlpassword }}"
-#          valueFrom:
-#            secretKeyRef:
-#              name: {{ template "common.fullname" . }}
-#              key: vid-password
         - name: MYSQL_HOST
           value: "{{ .Values.config.vidmysqlhost }}"
+        - name: MYSQL_USER
+          value: "{{ .Values.config.vidmysqluser }}"
+        - name: MYSQL_PORT
+          value: "{{ .Values.config.vidmysqlport }}"
+      restartPolicy: Never
       volumes:
-        - name: vid-db-config
-          configMap:
-            name: {{ include "common.fullname" . }}-galera-sql-configmap
-        - name: dbcmd-config
+        - name: {{ include "common.fullname" . }}-config
           configMap:
-            name: {{ include "common.fullname" . }}-dbcmd-configmap
-        - name: init-config
-          configMap:
-            name: {{ include "common.fullname" . }}-cluster-ready-configmap
-      restartPolicy: Never
-
+            name: {{ include "common.fullname" . }}
+            items:
+              - key: db_cmd.sh
+                path: db_cmd.sh
+              - key: vid-pre-init.sql
+                path: vid-pre-init.sql
 
index 4e5f403..34a265c 100644 (file)
@@ -17,9 +17,8 @@
 # Declare variables to be passed into your templates.
 global:
   nodePortPrefix: 302
-  repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ==
   readinessRepository: oomk8s
-  readinessImage: readiness-check:1.0.0
+  readinessImage: readiness-check:2.0.1
   loggingRepository: docker.elastic.co
   loggingImage: beats/filebeat:5.5.0
 
@@ -54,8 +53,9 @@ config:
   logstashPort: 5044
 
 # subchart configuration
-mariadb-galera:
-  nameOverride: vid-mariadb-galera
+vid_mariadb_galera:
+#  nameOverride: vid-mariadb-galera
+  replicaCount: 1
 
 # default number of instances
 replicaCount: 1