2bee19ffcf59e97578d41ed5bb7804067ba5b7ee
[oom.git] / kubernetes / aai / components / aai-graphadmin / templates / job-copy-db-backup.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" . }}-db-backup
43   namespace: {{ include "common.namespace" . }}
44   labels:
45     app: {{ include "common.name" . }}-job
46     release: {{ include "common.release" . }}
47     heritage: {{ .Release.Service }}
48     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
49   annotations:
50     "helm.sh/hook": pre-upgrade,pre-install
51     "helm.sh/hook-weight": "2"
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       {{ if eq .Values.global.jobs.migration.remoteCassandra.enabled false }}
64       - command:
65         - /bin/bash
66         - -c
67         {{- if .Values.global.cassandra.useOperator }}
68         - /app/ready.py --app-name aai-cassandra-reaper --timeout 1 || /app/ready.py --app-name cassandra-reaper
69         {{- else }}
70         - /app/ready.py --app-name aai-cassandra --timeout 1 || /app/ready.py --app-name cassandra
71         {{- end }}
72         env:
73         - name: NAMESPACE
74           valueFrom:
75             fieldRef:
76               apiVersion: v1
77               fieldPath: metadata.namespace
78         image: {{ include "repositoryGenerator.image.readiness" . }}
79         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
80         name: {{ include "common.name" . }}-db-backup-readiness
81       {{- end }}
82       containers:
83       - name: {{ include "common.name" . }}-db-backup-job
84         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
85         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
86         command:
87         - sh
88         args:
89         - -c
90         - |
91            {{- if include "common.onServiceMesh" . }}
92            echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
93            bash docker-entrypoint.sh dataSnapshot.sh;
94            {{ include "common.serviceMesh.killSidecar" . | indent 11 | trim }}
95         env:
96         - name: LOCAL_USER_ID
97           value: {{ .Values.securityContext.user_id | quote }}
98         - name: LOCAL_GROUP_ID
99           value: {{ .Values.securityContext.group_id | quote }}
100         volumeMounts:
101         - mountPath: /etc/localtime
102           name: localtime
103           readOnly: true
104         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
105           name: snapshots
106         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
107           name: migration
108           subPath: janusgraph-migration-real.properties
109         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
110           name: migration
111           subPath: janusgraph-migration-cached.properties
112         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
113           name: properties
114           subPath: aaiconfig.properties
115         - mountPath: /opt/aai/logroot/AAI-RES/
116           name: logs
117         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
118           name: config
119           subPath: logback.xml
120         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
121           name: config
122           subPath: localhost-access-logback.xml
123         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
124           name: properties
125           subPath: application.properties
126         resources: {{ include "common.resources" . | nindent 10 }}
127       {{- if .Values.nodeSelector }}
128       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
129       {{- end }}
130       {{- if .Values.affinity }}
131       affinity: {{ toYaml .Values.affinity | nindent 8 }}
132       {{- end }}
133       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
134       volumes:
135       - name: localtime
136         hostPath:
137           path: /etc/localtime
138       - name: logs
139         emptyDir: {}
140       - name: config
141         configMap:
142           name: {{ include "common.fullname" . }}
143       - name: properties
144         configMap:
145           name: {{ include "common.fullname" . }}-properties
146       - name: migration
147         configMap:
148           name: {{ include "common.fullname" . }}-migration
149       - name: snapshots
150         persistentVolumeClaim:
151           claimName: {{ include "common.fullname" . }}-migration
152       restartPolicy: Never
153       imagePullSecrets:
154       - name: "{{ include "common.namespace" . }}-docker-registry-key"
155 {{ end }}