[GENERAL] Use readiness container v3.0.1
[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   annotations:
29     "helm.sh/hook": post-install
30     "helm.sh/hook-weight": "0"
31     "helm.sh/hook-delete-policy": before-hook-creation
32 spec:
33   backoffLimit: 20
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}-job
38         release: {{ include "common.release" . }}
39       name: {{ include "common.name" . }}
40     spec:
41       initContainers:
42       - command:
43         - sh
44         args:
45         - -c
46         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
47         env:
48         - name: AAI_CLIENT_NAME
49           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
50         - name: AAI_CLIENT_PASSWORD
51           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
52         - name: MODELSERVICE_USER
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
54         - name: MODELSERVICE_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
56         - name: RESTCONF_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
58         - name: RESTCONF_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
60         - name: ANSIBLE_USER
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
62         - name: ANSIBLE_PASSWORD
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
64         - name: SCALEOUT_USER
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
66         - name: SCALEOUT_PASSWORD
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
68         - name: NETBOX_APIKEY
69           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
70         - name: SDNC_DB_USER
71           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
72         - name: SDNC_DB_PASSWORD
73           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
74         volumeMounts:
75         - mountPath: /config-input
76           name: config-input
77         - mountPath: /config
78           name: properties
79         image: "{{ .Values.global.envsubstImage }}"
80         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
81         name: {{ include "common.name" . }}-update-config
82
83       - name: {{ include "common.name" . }}-readiness
84         command:
85         - /app/ready.py
86         args:
87         - --container-name
88         - {{ include "common.mariadbService" . }}
89         env:
90         - name: NAMESPACE
91           valueFrom:
92             fieldRef:
93               apiVersion: v1
94               fieldPath: metadata.namespace
95         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
96         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
97       containers:
98       - name: {{ include "common.name" . }}
99         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
100         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
101         env:
102           - name: MYSQL_ROOT_PASSWORD
103             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
104           - name: ODL_ADMIN_USERNAME
105             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
106           - name: ODL_ADMIN_PASSWORD
107             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
108           - name: SDNC_DB_USER
109             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
110           - name: SDNC_DB_PASSWORD
111             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
112           - name: MYSQL_HOST
113             value: {{ include "common.mariadbService" . }}
114           - name: SDNC_HOME
115             value: "{{.Values.config.sdncHome}}"
116           - name: ETC_DIR
117             value: "{{.Values.config.etcDir}}"
118           - name: BIN_DIR
119             value: "{{.Values.config.binDir}}"
120           - name: SDNC_DB_DATABASE
121             value: "{{.Values.config.dbSdnctlDatabase}}"
122         volumeMounts:
123           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
124             name: bin
125             subPath: installSdncDb.sh
126           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
127             name: properties
128             subPath: svclogic.properties
129           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
130             name: properties
131             subPath: svclogic.properties
132           - mountPath: {{ .Values.config.configDir }}/dblib.properties
133             name: properties
134             subPath: dblib.properties
135         command:
136           - /bin/bash
137         args:
138           - {{.Values.config.binDir }}/installSdncDb.sh
139         resources:
140 {{ include "common.resources" . | indent 12 }}
141       {{- if .Values.nodeSelector }}
142       nodeSelector:
143 {{ toYaml .Values.nodeSelector | indent 10 }}
144       {{- end -}}
145       {{- if .Values.affinity }}
146       affinity:
147 {{ toYaml .Values.affinity | indent 10 }}
148       {{- end }}
149       volumes:
150       - name: localtime
151         hostPath:
152           path: /etc/localtime
153       - name: docker-entrypoint-initdb-d
154         emptyDir: {}
155       - name: bin
156         configMap:
157           name: {{ include "common.fullname" . }}-bin
158           defaultMode: 0755
159       - name: config-input
160         configMap:
161           name: {{ include "common.fullname" . }}-properties
162           defaultMode: 0644
163       - name: properties
164         emptyDir:
165           medium: Memory
166       restartPolicy: Never
167       imagePullSecrets:
168       - name: "{{ include "common.namespace" . }}-docker-registry-key"
169 {{- end -}}