| ################################################################################ |
| # Copyright (c) 2021 HCL Technolgies Limited. # |
| # # |
| # Licensed under the Apache License, Version 2.0 (the "License"); # |
| # you may not use this file except in compliance with the License. # |
| # You may obtain a copy of the License at # |
| # # |
| # http://www.apache.org/licenses/LICENSE-2.0 # |
| # # |
| # Unless required by applicable law or agreed to in writing, software # |
| # distributed under the License is distributed on an "AS IS" BASIS, # |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # |
| # See the License for the specific language governing permissions and # |
| # limitations under the License. # |
| ################################################################################ |
| {{- if .Values.backupRetention.enabled }} |
| apiVersion: batch/v1beta1 |
| kind: CronJob |
| metadata: |
| name: {{ include "common.fullname.influxdb" . }}-backup-retention |
| labels: |
| {{- include "common.influxdb.labels" . | nindent 4 }} |
| app.kubernetes.io/component: backup-retention |
| annotations: |
| {{- toYaml .Values.backupRetention.annotations | nindent 4 }} |
| spec: |
| schedule: {{ .Values.backupRetention.schedule | quote }} |
| startingDeadlineSeconds: {{ .Values.backupRetention.startingDeadlineSeconds }} |
| concurrencyPolicy: Forbid |
| jobTemplate: |
| spec: |
| template: |
| metadata: |
| {{- if .Values.backupRetention.podAnnotations }} |
| annotations: |
| {{ toYaml .Values.backupRetention.podAnnotations | nindent 12 }} |
| {{- end }} |
| labels: |
| {{- include "common.influxdb.selectorLabels" . | nindent 12 }} |
| spec: |
| restartPolicy: OnFailure |
| volumes: |
| - name: scripts |
| configMap: |
| name: {{ include "common.fullname.influxdb" . }}-backup-retention |
| {{- if .Values.backupRetention.gcs }} |
| {{- if .Values.backupRetention.gcs.serviceAccountSecret }} |
| - name: google-cloud-key |
| secret: |
| secretName: {{ .Values.backupRetention.gcs.serviceAccountSecret | quote }} |
| {{- end }} |
| {{- end }} |
| {{- if .Values.backupRetention.s3 }} |
| {{- if .Values.backupRetention.s3.credentialsSecret }} |
| - name: aws-credentials-secret |
| secret: |
| secretName: {{ .Values.backupRetention.s3.credentialsSecret | quote }} |
| {{- end }} |
| {{- end }} |
| serviceAccountName: {{ include "common.influxdb.serviceAccountName" . }} |
| containers: |
| {{- if .Values.backupRetention.gcs }} |
| {{- end }} |
| {{- if .Values.backupRetention.azure }} |
| {{- end }} |
| {{- if .Values.backupRetention.s3 }} |
| - name: aws-cli |
| image: amazon/aws-cli |
| command: ['/bin/bash'] |
| args: ['/scripts/backup-retention.sh'] |
| volumeMounts: |
| - name: scripts |
| mountPath: /scripts |
| {{- if .Values.backupRetention.s3.credentialsSecret}} |
| - name: aws-credentials-secret |
| mountPath: /var/secrets/aws/ |
| {{- end }} |
| env: |
| - name: AWS_CONFIG_FILE |
| value: /var/secrets/aws/credentials |
| - name: DAYS_TO_RETAIN |
| value: {{ .Values.backupRetention.daysToRetain | quote }} |
| - name: S3_BUCKET |
| value: {{ .Values.backupRetention.s3.bucketName }} |
| - name: S3_ENDPOINT |
| value: {{ .Values.backupRetention.s3.endpointUrl }} |
| resources: |
| {{- toYaml .Values.backupRetention.resources | nindent 14 }} |
| {{- end }} |
| {{- end }} |