[COMMON] Make imagePullSecrets configurable
[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: "500Mi"
87           requests:
88             cpu: "3m"
89             memory: "20Mi"
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       {{- include "common.imagePullSecrets" . | nindent 6 }}
198 ---
199 apiVersion: batch/v1
200 kind: Job
201 metadata:
202   name: {{ include "common.fullname" . }}-db-backup-job
203   namespace: {{ include "common.namespace" . }}
204   labels:
205     app: {{ include "common.name" . }}-db-backup-job
206     release: {{ include "common.release" . }}
207     heritage: {{ .Release.Service }}
208     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
209   annotations:
210     "helm.sh/hook": pre-upgrade,pre-install
211     "helm.sh/hook-weight": "2"
212     "helm.sh/hook-delete-policy": before-hook-creation
213 spec:
214   backoffLimit: 20
215   template:
216     metadata:
217       labels:
218         app: {{ include "common.name" . }}-db-backup-job
219         release: {{ include "common.release" . }}
220       name: {{ include "common.name" . }}
221     spec:
222       initContainers:
223       {{ if eq .Values.global.jobs.migration.remoteCassandra.enabled false }}
224       - command:
225         - /bin/bash
226         - -c
227         - /app/ready.py --app-name aai-cassandra --timeout 1 || /app/ready.py --app-name cassandra
228         env:
229         - name: NAMESPACE
230           valueFrom:
231             fieldRef:
232               apiVersion: v1
233               fieldPath: metadata.namespace
234         image: {{ include "repositoryGenerator.image.readiness" . }}
235         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
236         name: {{ include "common.name" . }}-db-backup-readiness
237         resources:
238           limits:
239             cpu: "100m"
240             memory: "500Mi"
241           requests:
242             cpu: "3m"
243             memory: "20Mi"
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         - sh
251         args:
252         - -c
253         - |
254            {{- if include "common.onServiceMesh" . }}
255            echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
256            bash docker-entrypoint.sh dataSnapshot.sh
257            {{ include "common.serviceMesh.killSidecar" . | indent 11 | trim }}
258         env:
259         - name: LOCAL_USER_ID
260           value: {{ .Values.securityContext.user_id | quote }}
261         - name: LOCAL_GROUP_ID
262           value: {{ .Values.securityContext.group_id | quote }}
263         volumeMounts:
264         - mountPath: /etc/localtime
265           name: localtime
266           readOnly: true
267         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
268           name: snapshots
269         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
270           name: migration
271           subPath: janusgraph-migration-real.properties
272         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
273           name: migration
274           subPath: janusgraph-migration-cached.properties
275         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
276           name: properties
277           subPath: aaiconfig.properties
278         - mountPath: /opt/aai/logroot/AAI-RES/
279           name: logs
280         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
281           name: config
282           subPath: logback.xml
283         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
284           name: config
285           subPath: localhost-access-logback.xml
286         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
287           name: properties
288           subPath: application.properties
289         resources: {{ include "common.resources" . | nindent 10 }}
290       {{- if .Values.nodeSelector }}
291       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
292       {{- end }}
293       {{- if .Values.affinity }}
294       affinity: {{ toYaml .Values.affinity | nindent 8 }}
295       {{- end }}
296       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
297       volumes: {{ include "common.resources" . | nindent 10 }}
298       - name: localtime
299         hostPath:
300           path: /etc/localtime
301       - name: logs
302         emptyDir: {}
303       - name: config
304         configMap:
305           name: {{ include "common.fullname" . }}
306       - name: properties-input
307         configMap:
308           name: {{ include "common.fullname" . }}-properties
309       - name: properties
310         emptyDir:
311           medium: Memory
312       - name: migration
313         configMap:
314           name: {{ include "common.fullname" . }}-migration
315       - name: snapshots
316         persistentVolumeClaim:
317           claimName: {{ include "common.fullname" . }}-migration
318       restartPolicy: Never
319       {{- include "common.imagePullSecrets" . | nindent 6 }}
320 {{ end }}