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