[SDNC] SDNC ServiceMesh compatibility
[oom.git] / kubernetes / sdnc / templates / job.yaml
1 {{- if .Values.dgbuilder.enabled -}}
2 {{/*
3 # Copyright © 2017 Amdocs, Bell Canada, AT&T
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 */}}
17
18 apiVersion: batch/v1
19 kind: Job
20 metadata:
21   name: {{ include "common.fullname" . }}-dbinit-job
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ include "common.release" . }}
27     heritage: {{ .Release.Service }}
28 spec:
29   backoffLimit: 20
30   template:
31     metadata:
32       labels:
33         app: {{ include "common.name" . }}-job
34         release: {{ include "common.release" . }}
35       name: {{ include "common.name" . }}
36     spec:
37       initContainers:
38       - command:
39         - sh
40         args:
41         - -c
42         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
43         env:
44         - name: AAI_CLIENT_NAME
45           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
46         - name: AAI_CLIENT_PASSWORD
47           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
48         - name: MODELSERVICE_USER
49           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
50         - name: MODELSERVICE_PASSWORD
51           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
52         - name: RESTCONF_USER
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
54         - name: RESTCONF_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
56         - name: ANSIBLE_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
58         - name: ANSIBLE_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
60         - name: SCALEOUT_USER
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
62         - name: SCALEOUT_PASSWORD
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
64         - name: NETBOX_APIKEY
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
66         - name: SDNC_DB_USER
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
68         - name: SDNC_DB_PASSWORD
69           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
70         volumeMounts:
71         - mountPath: /config-input
72           name: config-input
73         - mountPath: /config
74           name: properties
75         image: {{ include "repositoryGenerator.image.envsubst" . }}
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         name: {{ include "common.name" . }}-update-config
78
79       - name: {{ include "common.name" . }}-readiness
80         command:
81         - /app/ready.py
82         args:
83         - --container-name
84         - {{ include "common.mariadbService" . }}
85         env:
86         - name: NAMESPACE
87           valueFrom:
88             fieldRef:
89               apiVersion: v1
90               fieldPath: metadata.namespace
91         image: {{ include "repositoryGenerator.image.readiness" . }}
92         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
93       containers:
94       - name: {{ include "common.name" . }}
95         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
96         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
97         env:
98           - name: MYSQL_ROOT_PASSWORD
99             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
100           - name: ODL_ADMIN_USERNAME
101             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
102           - name: ODL_ADMIN_PASSWORD
103             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
104           - name: SDNC_DB_USER
105             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
106           - name: SDNC_DB_PASSWORD
107             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
108           - name: MYSQL_HOST
109             value: {{ include "common.mariadbService" . }}
110           - name: SDNC_HOME
111             value: "{{.Values.config.sdncHome}}"
112           - name: ETC_DIR
113             value: "{{.Values.config.etcDir}}"
114           - name: BIN_DIR
115             value: "{{.Values.config.binDir}}"
116           - name: SDNC_DB_DATABASE
117             value: "{{.Values.config.dbSdnctlDatabase}}"
118         volumeMounts:
119           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
120             name: bin
121             subPath: installSdncDb.sh
122           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
123             name: properties
124             subPath: svclogic.properties
125           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
126             name: properties
127             subPath: svclogic.properties
128           - mountPath: {{ .Values.config.configDir }}/dblib.properties
129             name: properties
130             subPath: dblib.properties
131         command:
132           - /bin/bash
133         args:
134           - -c
135           - |
136             sleep 60; {{.Values.config.binDir }}/installSdncDb.sh
137         resources: {{ include "common.resources" . | nindent 10 }}
138       {{- if include "common.onServiceMesh" . }}
139       - name: sdnc-service-mesh-wait-for-job-container
140         image: {{ include "repositoryGenerator.image.quitQuit" . }}
141         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
142         command:
143           - /bin/sh
144           - "-c"
145         args:
146           - |
147             echo "waiting 20s for istio side cars to be up"; sleep 20s;
148             /app/ready.py --service-mesh-check sdnc -t 45;
149         env:
150         - name: NAMESPACE
151           valueFrom:
152             fieldRef:
153               apiVersion: v1
154               fieldPath: metadata.namespace
155       {{- end }}
156       {{- if .Values.nodeSelector }}
157       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
158       {{- end }}
159       {{- if .Values.affinity }}
160       affinity: {{ toYaml .Values.affinity | nindent 8 }}
161       {{- end }}
162       volumes:
163       - name: localtime
164         hostPath:
165           path: /etc/localtime
166       - name: docker-entrypoint-initdb-d
167         emptyDir: {}
168       - name: bin
169         configMap:
170           name: {{ include "common.fullname" . }}-bin
171           defaultMode: 0755
172       - name: config-input
173         configMap:
174           name: {{ include "common.fullname" . }}-properties
175           defaultMode: 0644
176       - name: properties
177         emptyDir:
178           medium: Memory
179       restartPolicy: Never
180       imagePullSecrets:
181       - name: "{{ include "common.namespace" . }}-docker-registry-key"
182 {{- end -}}