blob: dd63a24253f799c6d7c354c114bc5f3d9818e992 [file] [log] [blame]
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +05301################################################################################
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################################################################################
Chandru22ebf742021-06-02 17:16:37 +053016{{- if .Values.backupRetention.enabled }}
17apiVersion: batch/v1beta1
18kind: CronJob
19metadata:
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +053020 name: {{ include "common.fullname.influxdb" . }}-backup-retention
Chandru22ebf742021-06-02 17:16:37 +053021 labels:
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +053022 {{- include "common.influxdb.labels" . | nindent 4 }}
Chandru22ebf742021-06-02 17:16:37 +053023 app.kubernetes.io/component: backup-retention
24 annotations:
25 {{- toYaml .Values.backupRetention.annotations | nindent 4 }}
26spec:
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:
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +053039 {{- include "common.influxdb.selectorLabels" . | nindent 12 }}
Chandru22ebf742021-06-02 17:16:37 +053040 spec:
41 restartPolicy: OnFailure
42 volumes:
43 - name: scripts
44 configMap:
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +053045 name: {{ include "common.fullname.influxdb" . }}-backup-retention
Chandru22ebf742021-06-02 17:16:37 +053046 {{- 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 }}
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +053060 serviceAccountName: {{ include "common.influxdb.serviceAccountName" . }}
Chandru22ebf742021-06-02 17:16:37 +053061 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 }}