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