[AAI] Uses new tpls for repos / images
[oom.git] / kubernetes / aai / components / aai-graphadmin / templates / job-migration.yaml
1 #
2 # ============LICENSE_START=======================================================
3 # org.onap.aai
4 # ================================================================================
5 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 # Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
7 # Copyright (c) 2020 Orange Intellectual Property. All rights reserved.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 #    http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END=========================================================
21
22 # In ONAP, the following job will always be run on each installation
23 # The following job will go through the latest oxm and
24 # create properties based on the data type defined in the oxm
25 # and create the required indexes for the appropriate properties
26 # This can be run multiple times as the code if the index or property already exists
27 # then the index or property won't be created again
28 # NOTE - During the execution of the createSchema job, there should
29 # be no other janusgraph connection to the graph as its the reason
30 # that resources traversal and graphadmin wait until this job is done
31 # If you are using an existing cassandra cluster not coming from oom
32 # then it is your job to ensure that there are no connections to the database
33
34 {{- if .Values.global.jobs.migration.enabled }}
35 ---
36 apiVersion: batch/v1
37 kind: Job
38 metadata:
39   name: {{ include "common.fullname" . }}-migration
40   namespace: {{ include "common.namespace" . }}
41   labels:
42     app: {{ include "common.name" . }}-job
43     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
44     release: {{ include "common.release" . }}
45     heritage: {{ .Release.Service }}
46   annotations:
47     "helm.sh/hook": post-upgrade,post-rollback,post-install
48     "helm.sh/hook-weight": "1"
49     "helm.sh/hook-delete-policy": before-hook-creation
50 spec:
51   backoffLimit: 20
52   template:
53     metadata:
54       labels:
55         app: {{ include "common.name" . }}-job
56         release: {{ include "common.release" . }}
57       name: {{ include "common.name" . }}
58     spec:
59       initContainers:
60       - command:
61         - /app/ready.py
62         args:
63         - --container-name
64         {{- if .Values.global.cassandra.localCluster }}
65         - aai-cassandra
66         {{- else }}
67         - cassandra
68         {{- end }}
69         - --container-name
70         - aai-schema-service
71         env:
72         - name: NAMESPACE
73           valueFrom:
74             fieldRef:
75               apiVersion: v1
76               fieldPath: metadata.namespace
77         image: {{ include "repositoryGenerator.image.readiness" . }}
78         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
79         name: {{ include "common.name" . }}-readiness
80       - command:
81         - /bin/bash
82         - -c
83         - bash docker-entrypoint.sh dataRestoreFromSnapshot.sh `ls -t /opt/app/aai-graphadmin/logs/data/dataSnapshots|head -1|awk -F".P" '{ print $1 }'`
84         env:
85         - name: LOCAL_USER_ID
86           value: {{ .Values.global.config.userId | quote }}
87         - name: LOCAL_GROUP_ID
88           value: {{ .Values.global.config.groupId | quote }}
89         volumeMounts:
90         - mountPath: /etc/localtime
91           name: localtime
92           readOnly: true
93         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
94           name: {{ include "common.fullname" . }}-config
95           subPath: janusgraph-realtime.properties
96         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
97           name: {{ include "common.fullname" . }}-snapshots
98         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
99           name: {{ include "common.fullname" . }}-config
100           subPath: janusgraph-cached.properties
101         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
102           name: {{ include "common.fullname" . }}-config
103           subPath: aaiconfig.properties
104         - mountPath: /opt/aai/logroot/AAI-GA
105           name: {{ include "common.fullname" . }}-logs
106         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
107           name: {{ include "common.fullname" . }}-config
108           subPath: logback.xml
109         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
110           name: {{ include "common.fullname" . }}-config
111           subPath: localhost-access-logback.xml
112         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
113           name: {{ include "common.fullname" . }}-config
114           subPath: application.properties
115           {{ $global := . }}
116           {{ range $job := .Values.global.config.auth.files }}
117         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/{{ . }}
118           name: {{ include "common.fullname" $global }}-auth-truststore-sec
119           subPath: {{ . }}
120           {{ end }}
121         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
122         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
123         name: {{ include "common.name" . }}-restore-backup
124       containers:
125       - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
126         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
127         name: {{ include "common.name" . }}-perform-migration
128         command:
129         - /bin/bash
130         - -c
131         - bash docker-entrypoint.sh run_Migrations.sh -e UpdateAaiUriIndexMigration --commit --skipPreMigrationSnapShot --runDisabled RebuildAllEdges
132         env:
133         - name: LOCAL_USER_ID
134           value: {{ .Values.global.config.userId | quote }}
135         - name: LOCAL_GROUP_ID
136           value: {{ .Values.global.config.groupId | quote }}
137         volumeMounts:
138         - mountPath: /etc/localtime
139           name: localtime
140           readOnly: true
141         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
142           name: {{ include "common.fullname" . }}-config
143           subPath: janusgraph-realtime.properties
144         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
145           name: {{ include "common.fullname" . }}-config
146           subPath: janusgraph-cached.properties
147         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
148           name: {{ include "common.fullname" . }}-config
149           subPath: aaiconfig.properties
150         - mountPath: /opt/aai/logroot/AAI-GA
151           name: {{ include "common.fullname" . }}-logs
152         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
153           name: {{ include "common.fullname" . }}-config
154           subPath: logback.xml
155         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
156           name: {{ include "common.fullname" . }}-config
157           subPath: localhost-access-logback.xml
158         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
159           name: {{ include "common.fullname" . }}-config
160           subPath: application.properties
161           {{ $global := . }}
162           {{ range $job := .Values.global.config.auth.files }}
163         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/{{ . }}
164           name: {{ include "common.fullname" $global }}-auth-truststore-sec
165           subPath: {{ . }}
166           {{ end }}
167         resources:
168 {{ include "common.resources" . }}
169       {{- if .Values.nodeSelector }}
170       nodeSelector:
171 {{ toYaml .Values.nodeSelector | indent 8 }}
172       {{- end -}}
173       {{- if .Values.affinity }}
174       affinity:
175 {{ toYaml .Values.affinity | indent 8 }}
176       {{- end }}
177       volumes:
178       - name: localtime
179         hostPath:
180           path: /etc/localtime
181       - name: filebeat-conf
182         configMap:
183           name: aai-filebeat
184       - name: {{ include "common.fullname" . }}-logs
185         emptyDir: {}
186       - name: {{ include "common.fullname" . }}-config
187         configMap:
188           name: {{ include "common.fullname" . }}-configmap
189       - name: {{ include "common.fullname" . }}-snapshots
190         persistentVolumeClaim:
191           claimName: {{ include "common.fullname" . }}-migration
192       - name: {{ include "common.fullname" . }}-auth-truststore-sec
193         secret:
194           secretName: aai-common-truststore
195           items:
196             {{ range $job := .Values.global.config.auth.files }}
197             - key: {{ . }}
198               path: {{ . }}
199             {{ end }}
200       restartPolicy: Never
201       imagePullSecrets:
202       - name: "{{ include "common.namespace" . }}-docker-registry-key"
203 ---
204 apiVersion: batch/v1
205 kind: Job
206 metadata:
207   name: {{ include "common.fullname" . }}-db-backup-job
208   namespace: {{ include "common.namespace" . }}
209   labels:
210     app: {{ include "common.name" . }}-db-backup-job
211     release: {{ include "common.release" . }}
212     heritage: {{ .Release.Service }}
213     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
214   annotations:
215     "helm.sh/hook": pre-upgrade,pre-install
216     "helm.sh/hook-weight": "2"
217     "helm.sh/hook-delete-policy": before-hook-creation
218 spec:
219   backoffLimit: 20
220   template:
221     metadata:
222       labels:
223         app: {{ include "common.name" . }}-db-backup-job
224         release: {{ include "common.release" . }}
225       name: {{ include "common.name" . }}
226     spec:
227       {{ if eq .Values.global.jobs.migration.remoteCassandra.enabled false }}
228       initContainers:
229       - command:
230         - /bin/bash
231         - -c
232         - /app/ready.py --container-name aai-cassandra --timeout 1 || /app/ready.py --container-name cassandra
233         env:
234         - name: NAMESPACE
235           valueFrom:
236             fieldRef:
237               apiVersion: v1
238               fieldPath: metadata.namespace
239         image: {{ include "repositoryGenerator.image.readiness" . }}
240         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
241         name: {{ include "common.name" . }}-db-backup-readiness
242       {{- end }}
243       containers:
244       - name: {{ include "common.name" . }}-db-backup-job
245         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
246         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
247         command:
248         - /bin/bash
249         - docker-entrypoint.sh
250         - dataSnapshot.sh
251         env:
252         - name: LOCAL_USER_ID
253           value: {{ .Values.global.config.userId | quote }}
254         - name: LOCAL_GROUP_ID
255           value: {{ .Values.global.config.groupId | quote }}
256         volumeMounts:
257         - mountPath: /etc/localtime
258           name: localtime
259           readOnly: true
260         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
261           name: {{ include "common.fullname" . }}-snapshots
262         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
263           name: {{ include "common.fullname" . }}-migration
264           subPath: janusgraph-migration-real.properties
265         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
266           name: {{ include "common.fullname" . }}-migration
267           subPath: janusgraph-migration-cached.properties
268         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
269           name: {{ include "common.fullname" . }}-config
270           subPath: aaiconfig.properties
271         - mountPath: /opt/aai/logroot/AAI-RES/
272           name: {{ include "common.fullname" . }}-logs
273         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
274           name: {{ include "common.fullname" . }}-config
275           subPath: logback.xml
276         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
277           name: {{ include "common.fullname" . }}-config
278           subPath: localhost-access-logback.xml
279         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
280           name: {{ include "common.fullname" . }}-config
281           subPath: application.properties
282         resources:
283 {{ include "common.resources" . | indent 10 }}
284       {{- if .Values.nodeSelector }}
285       nodeSelector:
286 {{ toYaml .Values.nodeSelector | indent 8 }}
287       {{- end -}}
288       {{- if .Values.affinity }}
289       affinity:
290 {{ toYaml .Values.affinity | indent 8 }}
291       {{- end }}
292       volumes:
293       - name: localtime
294         hostPath:
295           path: /etc/localtime
296       - name: {{ include "common.fullname" . }}-logs
297         emptyDir: {}
298       - name: {{ include "common.fullname" . }}-config
299         configMap:
300           name: {{ include "common.fullname" . }}-configmap
301       - name: {{ include "common.fullname" . }}-migration
302         configMap:
303           name: {{ include "common.fullname" . }}-migration-configmap
304       - name: {{ include "common.fullname" . }}-snapshots
305         persistentVolumeClaim:
306           claimName: {{ include "common.fullname" . }}-migration
307       restartPolicy: Never
308       imagePullSecrets:
309       - name: "{{ include "common.namespace" . }}-docker-registry-key"
310 {{ end }}