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