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