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