1 ################################################################################
2 # Copyright (c) 2021 HCL Technolgies Limited. #
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 #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
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.backup.enabled }}
17 apiVersion: batch/v1beta1
20 name: {{ include "common.fullname.influxdb" . }}-backup
22 {{- include "common.influxdb.labels" . | nindent 4 }}
23 app.kubernetes.io/component: backup
25 {{- toYaml .Values.backup.annotations | nindent 4 }}
27 schedule: {{ .Values.backup.schedule | quote }}
28 startingDeadlineSeconds: {{ .Values.backup.startingDeadlineSeconds }}
29 concurrencyPolicy: Forbid
34 {{- if .Values.backup.podAnnotations }}
36 {{ toYaml .Values.backup.podAnnotations | nindent 12 }}
39 {{- include "common.influxdb.selectorLabels" . | nindent 12 }}
41 restartPolicy: OnFailure
44 {{- if .Values.backup.persistence.enabled }}
45 persistentVolumeClaim:
46 claimName: {{ include "common.fullname.influxdb" . }}-backup
50 {{- if .Values.backup.gcs }}
51 {{- if .Values.backup.gcs.serviceAccountSecret }}
52 - name: google-cloud-key
54 secretName: {{ .Values.backup.gcs.serviceAccountSecret | quote }}
57 {{- if .Values.backup.s3 }}
58 {{- if .Values.backup.s3.credentialsSecret }}
59 - name: aws-credentials-secret
61 secretName: {{ .Values.backup.s3.credentialsSecret | quote }}
64 serviceAccountName: {{ include "common.influxdb.serviceAccountName" . }}
66 - name: influxdb-backup
67 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
77 -host {{ include "common.fullname.influxdb" . }}.{{ .Release.Namespace }}.svc:{{ include "common.serviceport.influxdb.rpc.bind_address" . | default 8088 }} \
78 -portable /backup/"$(date +%Y%m%d%H%M%S)"
80 {{- toYaml .Values.backup.resources | nindent 14 }}
82 {{- if .Values.backup.gcs }}
84 image: google/cloud-sdk:alpine
91 if [ -n "$KEY_FILE" ]; then
92 gcloud auth activate-service-account --key-file $KEY_FILE
94 gsutil -m cp -r /backup/* "$DST_URL"
99 {{- if .Values.backup.gcs.serviceAccountSecretKey}}
100 - name: google-cloud-key
101 mountPath: /var/secrets/google/
105 value: {{ .Values.backup.gcs.destination}}
106 {{- if .Values.backup.gcs.serviceAccountSecretKey}}
108 value: /var/secrets/google/{{ .Values.backup.gcs.serviceAccountSecretKey }}
111 {{- toYaml .Values.backup.resources | nindent 14 }}
113 {{- if .Values.backup.azure }}
115 image: microsoft/azure-cli
122 az storage container create --name "$DST_CONTAINER"
123 az storage blob upload-batch --destination "$DST_CONTAINER" --destination-path "$DST_PATH" --source "$SRC_URL"
131 - name: DST_CONTAINER
132 value: {{ .Values.backup.azure.destination_container }}
134 value: {{ .Values.backup.azure.destination_path }}
135 - name: AZURE_STORAGE_CONNECTION_STRING
138 name: {{ .Values.backup.azure.storageAccountSecret }}
139 key: connection-string
141 {{- toYaml .Values.backup.resources | nindent 14 }}
143 {{- if .Values.backup.s3 }}
145 image: amazon/aws-cli
152 aws {{- if .Values.backup.s3.endpointUrl }} --endpoint-url={{ .Values.backup.s3.endpointUrl }} {{- end }} s3 cp --recursive "$SRC_URL" "$DST_URL"
157 {{- if .Values.backup.s3.credentialsSecret}}
158 - name: aws-credentials-secret
159 mountPath: /var/secrets/aws/
162 - name: AWS_CONFIG_FILE
163 value: /var/secrets/aws/credentials
167 value: {{ .Values.backup.s3.destination }}
169 {{- toYaml .Values.backup.resources | nindent 14 }}