Issue-ID: RICAPP-169 - Inclusion of InfluxDB helm chart for KPIMON, AD, TS, QP xApps
[ric-plt/ric-dep.git] / helm / 3rdparty / influxdb / templates / backup-retention-cronjob.yaml
1 ################################################################################
2 #   Copyright (c) 2021 HCL Technolgies Limited.                                #
3 #                                                                              #
4 #   Licensed under the Apache License, Version 2.0 (the "License");            #
5 #   you may not use this file except in compliance with the License.           #
6 #   You may obtain a copy of the License at                                    #
7 #                                                                              #
8 #       http://www.apache.org/licenses/LICENSE-2.0                             #
9 #                                                                              #
10 #   Unless required by applicable law or agreed to in writing, software        #
11 #   distributed under the License is distributed on an "AS IS" BASIS,          #
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13 #   See the License for the specific language governing permissions and        #
14 #   limitations under the License.                                             #
15 ################################################################################
16 {{- if .Values.backupRetention.enabled }}
17 apiVersion: batch/v1beta1
18 kind: CronJob
19 metadata:
20   name: {{ include "common.fullname.influxdb" . }}-backup-retention
21   labels:
22     {{- include "common.influxdb.labels" . | nindent 4 }}
23     app.kubernetes.io/component: backup-retention
24   annotations:
25     {{- toYaml .Values.backupRetention.annotations | nindent 4 }}
26 spec:
27   schedule: {{ .Values.backupRetention.schedule | quote }}
28   startingDeadlineSeconds: {{ .Values.backupRetention.startingDeadlineSeconds }}
29   concurrencyPolicy: Forbid
30   jobTemplate:
31     spec:
32       template:
33         metadata:
34           {{- if .Values.backupRetention.podAnnotations }}
35           annotations:
36             {{ toYaml .Values.backupRetention.podAnnotations | nindent 12 }}
37           {{- end }}
38           labels:
39             {{- include "common.influxdb.selectorLabels" . | nindent 12 }}
40         spec:
41           restartPolicy: OnFailure
42           volumes:
43           - name: scripts
44             configMap:
45               name: {{ include "common.fullname.influxdb" . }}-backup-retention
46           {{- if .Values.backupRetention.gcs }}
47           {{- if .Values.backupRetention.gcs.serviceAccountSecret }}
48           - name: google-cloud-key
49             secret:
50               secretName: {{ .Values.backupRetention.gcs.serviceAccountSecret | quote }}
51           {{- end }}
52           {{- end }}
53           {{- if .Values.backupRetention.s3 }}
54           {{- if .Values.backupRetention.s3.credentialsSecret }}
55           - name: aws-credentials-secret
56             secret:
57               secretName: {{ .Values.backupRetention.s3.credentialsSecret | quote }}
58           {{- end }}
59           {{- end }}
60           serviceAccountName: {{ include "common.influxdb.serviceAccountName" . }}
61           containers:
62           {{- if .Values.backupRetention.gcs }}
63           {{- end }}
64           {{- if .Values.backupRetention.azure }}
65           {{- end }}
66           {{- if .Values.backupRetention.s3 }}
67           - name: aws-cli
68             image: amazon/aws-cli
69             command: ['/bin/bash']
70             args: ['/scripts/backup-retention.sh']
71             volumeMounts:
72             - name: scripts
73               mountPath: /scripts
74             {{- if .Values.backupRetention.s3.credentialsSecret}}
75             - name: aws-credentials-secret
76               mountPath: /var/secrets/aws/
77             {{- end }}
78             env:
79               - name: AWS_CONFIG_FILE
80                 value: /var/secrets/aws/credentials
81               - name: DAYS_TO_RETAIN
82                 value: {{ .Values.backupRetention.daysToRetain | quote }}
83               - name: S3_BUCKET
84                 value: {{ .Values.backupRetention.s3.bucketName }}
85               - name: S3_ENDPOINT
86                 value: {{ .Values.backupRetention.s3.endpointUrl }}
87             resources:
88               {{- toYaml .Values.backupRetention.resources | nindent 14 }}
89           {{- end }}
90 {{- end }}