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