summaryrefslogtreecommitdiffstats
path: root/kubernetes/vid/templates
diff options
context:
space:
mode:
authorMandeep Khinda <Mandeep.Khinda@amdocs.com>2018-09-18 15:02:03 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-18 15:02:03 +0000
commit772db528bf73a61252f474d81fc868094acd1351 (patch)
tree39ac22b973cc5e93f78d42aced9c24f722c92d97 /kubernetes/vid/templates
parent8e7186a17548795ca2f075057761ad2e5f006f01 (diff)
parent561a91cadd2f75c831a3e4743365f58c82e951d3 (diff)
Merge "Vid Template alignment."
Diffstat (limited to 'kubernetes/vid/templates')
-rw-r--r--kubernetes/vid/templates/check-job-completion-configmap.yaml97
-rw-r--r--kubernetes/vid/templates/cluster-ready-configmap.yaml103
-rw-r--r--kubernetes/vid/templates/configmap.yaml13
-rw-r--r--kubernetes/vid/templates/dbcmd-configmap.yaml25
-rw-r--r--kubernetes/vid/templates/deployment.yaml16
-rw-r--r--kubernetes/vid/templates/galera-sql-configmap.yaml35
-rw-r--r--kubernetes/vid/templates/vid-galera-config-job.yaml59
7 files changed, 42 insertions, 306 deletions
diff --git a/kubernetes/vid/templates/check-job-completion-configmap.yaml b/kubernetes/vid/templates/check-job-completion-configmap.yaml
deleted file mode 100644
index 270615a04b..0000000000
--- a/kubernetes/vid/templates/check-job-completion-configmap.yaml
+++ /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
index 86f8d9129b..0000000000
--- a/kubernetes/vid/templates/cluster-ready-configmap.yaml
+++ /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)
-
-
-
diff --git a/kubernetes/vid/templates/configmap.yaml b/kubernetes/vid/templates/configmap.yaml
index f7dbf07645..cae46b4050 100644
--- a/kubernetes/vid/templates/configmap.yaml
+++ b/kubernetes/vid/templates/configmap.yaml
@@ -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
diff --git a/kubernetes/vid/templates/dbcmd-configmap.yaml b/kubernetes/vid/templates/dbcmd-configmap.yaml
deleted file mode 100644
index aa088011ea..0000000000
--- a/kubernetes/vid/templates/dbcmd-configmap.yaml
+++ /dev/null
@@ -1,25 +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" . }}-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
-
diff --git a/kubernetes/vid/templates/deployment.yaml b/kubernetes/vid/templates/deployment.yaml
index 5c98b04ae8..5cd4f38331 100644
--- a/kubernetes/vid/templates/deployment.yaml
+++ b/kubernetes/vid/templates/deployment.yaml
@@ -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
index 7f05af56a9..0000000000
--- a/kubernetes/vid/templates/galera-sql-configmap.yaml
+++ /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;
-
diff --git a/kubernetes/vid/templates/vid-galera-config-job.yaml b/kubernetes/vid/templates/vid-galera-config-job.yaml
index b893dbf617..2bcf64749d 100644
--- a/kubernetes/vid/templates/vid-galera-config-job.yaml
+++ b/kubernetes/vid/templates/vid-galera-config-job.yaml
@@ -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