[COMMON] Harmonize resource settings
[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         - --app-name
67         {{- if .Values.global.cassandra.localCluster }}
68         - aai-cassandra
69         {{- else }}
70         - cassandra
71         {{- end }}
72         - --container-name
73         - aai-schema-service
74         env:
75         - name: NAMESPACE
76           valueFrom:
77             fieldRef:
78               apiVersion: v1
79               fieldPath: metadata.namespace
80         image: {{ include "repositoryGenerator.image.readiness" . }}
81         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
82         name: {{ include "common.name" . }}-readiness
83         resources:
84           limits:
85             cpu: "100m"
86             memory: "0.5Gi"
87           requests:
88             cpu: "3m"
89             memory: "0.02Gi"
90       - command:
91         - sh
92         args:
93         - -c
94         - |
95            bash docker-entrypoint.sh dataRestoreFromSnapshot.sh `ls -t /opt/app/aai-graphadmin/logs/data/dataSnapshots|head -1|awk -F".P" '{ print $1 }'`
96         env:
97         - name: LOCAL_USER_ID
98           value: {{ .Values.securityContext.user_id | quote }}
99         - name: LOCAL_GROUP_ID
100           value: {{ .Values.securityContext.group_id | quote }}
101         volumeMounts:
102         - mountPath: /etc/localtime
103           name: localtime
104           readOnly: true
105         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
106           name: config
107           subPath: janusgraph-realtime.properties
108         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
109           name: snapshots
110         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
111           name: config
112           subPath: janusgraph-cached.properties
113         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
114           name: properties
115           subPath: aaiconfig.properties
116         - mountPath: /opt/aai/logroot/AAI-GA
117           name: logs
118         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
119           name: config
120           subPath: logback.xml
121         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
122           name: config
123           subPath: localhost-access-logback.xml
124         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
125           name: properties
126           subPath: application.properties
127         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
128         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
129         name: {{ include "common.name" . }}-restore-backup
130       containers:
131       - image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
132         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
133         name: {{ include "common.name" . }}-perform-migration
134         command:
135         - sh
136         args:
137         - -c
138         - |
139            {{- if include "common.onServiceMesh" . }}
140            echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
141            bash docker-entrypoint.sh run_Migrations.sh -e UpdateAaiUriIndexMigration --commit --skipPreMigrationSnapShot --runDisabled RebuildAllEdges ;
142            {{ include "common.serviceMesh.killSidecar" . | indent 11 | trim }}
143         env:
144         - name: LOCAL_USER_ID
145           value: {{ .Values.securityContext.user_id | quote }}
146         - name: LOCAL_GROUP_ID
147           value: {{ .Values.securityContext.group_id | quote }}
148         volumeMounts:
149         - mountPath: /etc/localtime
150           name: localtime
151           readOnly: true
152         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
153           name: config
154           subPath: janusgraph-realtime.properties
155         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
156           name: config
157           subPath: janusgraph-cached.properties
158         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
159           name: properties
160           subPath: aaiconfig.properties
161         - mountPath: /opt/aai/logroot/AAI-GA
162           name: logs
163         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
164           name: config
165           subPath: logback.xml
166         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
167           name: config
168           subPath: localhost-access-logback.xml
169         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
170           name: properties
171           subPath: application.properties
172         resources: {{ include "common.resources" . | nindent 10 }}
173       {{- if .Values.nodeSelector }}
174       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
175       {{- end }}
176       {{- if .Values.affinity }}
177       affinity: {{ toYaml .Values.affinity | nindent 8 }}
178       {{- end }}
179       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
180       volumes:
181       - name: localtime
182         hostPath:
183           path: /etc/localtime
184       {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 8 }}
185       - name: {{ include "common.fullname" . }}-logs
186         emptyDir: {}
187       - name: {{ include "common.fullname" . }}-config
188         configMap:
189           name: {{ include "common.fullname" . }}-configmap
190       - name: {{ include "common.fullname" . }}-snapshots
191         persistentVolumeClaim:
192           claimName: {{ include "common.fullname" . }}-migration
193       - name: properties
194         configMap:
195           name: {{ include "common.fullname" . }}-properties
196       restartPolicy: Never
197       imagePullSecrets:
198       - name: "{{ include "common.namespace" . }}-docker-registry-key"
199 ---
200 apiVersion: batch/v1
201 kind: Job
202 metadata:
203   name: {{ include "common.fullname" . }}-db-backup-job
204   namespace: {{ include "common.namespace" . }}
205   labels:
206     app: {{ include "common.name" . }}-db-backup-job
207     release: {{ include "common.release" . }}
208     heritage: {{ .Release.Service }}
209     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
210   annotations:
211     "helm.sh/hook": pre-upgrade,pre-install
212     "helm.sh/hook-weight": "2"
213     "helm.sh/hook-delete-policy": before-hook-creation
214 spec:
215   backoffLimit: 20
216   template:
217     metadata:
218       labels:
219         app: {{ include "common.name" . }}-db-backup-job
220         release: {{ include "common.release" . }}
221       name: {{ include "common.name" . }}
222     spec:
223       initContainers:
224       {{ if eq .Values.global.jobs.migration.remoteCassandra.enabled false }}
225       - command:
226         - /bin/bash
227         - -c
228         - /app/ready.py --app-name aai-cassandra --timeout 1 || /app/ready.py --app-name cassandra
229         env:
230         - name: NAMESPACE
231           valueFrom:
232             fieldRef:
233               apiVersion: v1
234               fieldPath: metadata.namespace
235         image: {{ include "repositoryGenerator.image.readiness" . }}
236         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
237         name: {{ include "common.name" . }}-db-backup-readiness
238         resources:
239           limits:
240             cpu: "100m"
241             memory: "0.5Gi"
242           requests:
243             cpu: "3m"
244             memory: "0.02Gi"
245       {{- end }}
246       containers:
247       - name: {{ include "common.name" . }}-db-backup-job
248         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
249         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
250         command:
251         - sh
252         args:
253         - -c
254         - |
255            {{- if include "common.onServiceMesh" . }}
256            echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
257            bash docker-entrypoint.sh dataSnapshot.sh
258            {{ include "common.serviceMesh.killSidecar" . | indent 11 | trim }}
259         env:
260         - name: LOCAL_USER_ID
261           value: {{ .Values.securityContext.user_id | quote }}
262         - name: LOCAL_GROUP_ID
263           value: {{ .Values.securityContext.group_id | quote }}
264         volumeMounts:
265         - mountPath: /etc/localtime
266           name: localtime
267           readOnly: true
268         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
269           name: snapshots
270         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
271           name: migration
272           subPath: janusgraph-migration-real.properties
273         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
274           name: migration
275           subPath: janusgraph-migration-cached.properties
276         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
277           name: properties
278           subPath: aaiconfig.properties
279         - mountPath: /opt/aai/logroot/AAI-RES/
280           name: logs
281         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
282           name: config
283           subPath: logback.xml
284         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
285           name: config
286           subPath: localhost-access-logback.xml
287         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
288           name: properties
289           subPath: application.properties
290         resources: {{ include "common.resources" . | nindent 10 }}
291       {{- if .Values.nodeSelector }}
292       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
293       {{- end }}
294       {{- if .Values.affinity }}
295       affinity: {{ toYaml .Values.affinity | nindent 8 }}
296       {{- end }}
297       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
298       volumes: {{ include "common.resources" . | nindent 10 }}
299       - name: localtime
300         hostPath:
301           path: /etc/localtime
302       - name: logs
303         emptyDir: {}
304       - name: config
305         configMap:
306           name: {{ include "common.fullname" . }}
307       - name: properties-input
308         configMap:
309           name: {{ include "common.fullname" . }}-properties
310       - name: properties
311         emptyDir:
312           medium: Memory
313       - name: migration
314         configMap:
315           name: {{ include "common.fullname" . }}-migration
316       - name: snapshots
317         persistentVolumeClaim:
318           claimName: {{ include "common.fullname" . }}-migration
319       restartPolicy: Never
320       imagePullSecrets:
321       - name: "{{ include "common.namespace" . }}-docker-registry-key"
322 {{ end }}