[AAI] Reintegrate AAI OOM charts in main repo
[oom.git] / kubernetes / aai / components / aai-graphadmin / templates / job-copy-db-backup.yaml
1 #
2 # ============LICENSE_START=======================================================
3 # org.onap.aai
4 # ================================================================================
5 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 # Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #    http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END=========================================================
20
21 # In ONAP, the following job will always be run on each installation
22 # The following job will go through the latest oxm and
23 # create properties based on the data type defined in the oxm
24 # and create the required indexes for the appropriate properties
25 # This can be run multiple times as the code if the index or property already exists
26 # then the index or property won't be created again
27 # NOTE - During the execution of the createSchema job, there should
28 # be no other janusgraph connection to the graph as its the reason
29 # that resources traversal and graphadmin wait until this job is done
30 # If you are using an existing cassandra cluster not coming from oom
31 # then it is your job to ensure that there are no connections to the database
32
33 {{- if .Values.global.jobs.migration.enabled }}
34 ---
35 apiVersion: batch/v1
36 kind: Job
37 metadata:
38   name: {{ include "common.fullname" . }}-db-backup
39   namespace: {{ include "common.namespace" . }}
40   labels:
41     app: {{ include "common.name" . }}-job
42     release: {{ include "common.release" . }}
43     heritage: {{ .Release.Service }}
44     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
45   annotations:
46     "helm.sh/hook": pre-upgrade,pre-install
47     "helm.sh/hook-weight": "2"
48     "helm.sh/hook-delete-policy": before-hook-creation
49 spec:
50   backoffLimit: 20
51   template:
52     metadata:
53       labels:
54         app: {{ include "common.name" . }}-job
55         release: {{ include "common.release" . }}
56       name: {{ include "common.name" . }}
57     spec:
58       {{ if eq .Values.global.jobs.migration.remoteCassandra.enabled false }}
59       initContainers:
60       - command:
61         - /bin/bash
62         - -c
63         - /app/ready.py --container-name aai-cassandra --timeout 1 || /app/ready.py --container-name cassandra
64         env:
65         - name: NAMESPACE
66           valueFrom:
67             fieldRef:
68               apiVersion: v1
69               fieldPath: metadata.namespace
70         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         name: {{ include "common.name" . }}-db-backup-readiness
73       {{- end }}
74       containers:
75       - name: {{ include "common.name" . }}-db-backup-job
76         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         command:
79         - /bin/bash
80         - docker-entrypoint.sh
81         - dataSnapshot.sh
82         env:
83         - name: LOCAL_USER_ID
84           value: {{ .Values.global.config.userId | quote }}
85         - name: LOCAL_GROUP_ID
86           value: {{ .Values.global.config.groupId | quote }}
87         volumeMounts:
88         - mountPath: /etc/localtime
89           name: localtime
90           readOnly: true
91         - mountPath: /opt/app/aai-graphadmin/logs/data/dataSnapshots
92           name: {{ include "common.fullname" . }}-snapshots
93         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
94           name: {{ include "common.fullname" . }}-migration
95           subPath: janusgraph-migration-real.properties
96         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
97           name: {{ include "common.fullname" . }}-migration
98           subPath: janusgraph-migration-cached.properties
99         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
100           name: {{ include "common.fullname" . }}-config
101           subPath: aaiconfig.properties
102         - mountPath: /opt/aai/logroot/AAI-RES/
103           name: {{ include "common.fullname" . }}-logs
104         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
105           name: {{ include "common.fullname" . }}-config
106           subPath: logback.xml
107         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
108           name: {{ include "common.fullname" . }}-config
109           subPath: localhost-access-logback.xml
110         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
111           name: {{ include "common.fullname" . }}-config
112           subPath: application.properties
113         resources:
114 {{ include "common.resources" . | indent 10 }}
115       {{- if .Values.nodeSelector }}
116       nodeSelector:
117 {{ toYaml .Values.nodeSelector | indent 8 }}
118       {{- end -}}
119       {{- if .Values.affinity }}
120       affinity:
121 {{ toYaml .Values.affinity | indent 8 }}
122       {{- end }}
123       volumes:
124       - name: localtime
125         hostPath:
126           path: /etc/localtime
127       - name: {{ include "common.fullname" . }}-logs
128         emptyDir: {}
129       - name: {{ include "common.fullname" . }}-config
130         configMap:
131          name: {{ include "common.fullname" . }}-configmap
132       - name: {{ include "common.fullname" . }}-migration
133         configMap:
134          name: {{ include "common.fullname" . }}-migration-configmap
135       - name: {{ include "common.fullname" . }}-snapshots
136         persistentVolumeClaim:
137           claimName: {{ include "common.fullname" . }}-migration
138       restartPolicy: Never
139       imagePullSecrets:
140       - name: "{{ include "common.namespace" . }}-docker-registry-key"
141 {{ end }}