1 {{- if .Values.backup.enabled }}
2 apiVersion: batch/v1beta1
5 name: {{ include "influxdb.fullname" . }}-backup
7 {{- include "influxdb.labels" . | nindent 4 }}
8 app.kubernetes.io/component: backup
10 {{- toYaml .Values.backup.annotations | nindent 4 }}
12 schedule: {{ .Values.backup.schedule | quote }}
13 startingDeadlineSeconds: {{ .Values.backup.startingDeadlineSeconds }}
14 concurrencyPolicy: Forbid
19 {{- if .Values.backup.podAnnotations }}
21 {{ toYaml .Values.backup.podAnnotations | nindent 12 }}
24 {{- include "influxdb.selectorLabels" . | nindent 12 }}
26 restartPolicy: OnFailure
29 {{- if .Values.backup.persistence.enabled }}
30 persistentVolumeClaim:
31 claimName: {{ include "influxdb.fullname" . }}-backup
35 {{- if .Values.backup.gcs }}
36 {{- if .Values.backup.gcs.serviceAccountSecret }}
37 - name: google-cloud-key
39 secretName: {{ .Values.backup.gcs.serviceAccountSecret | quote }}
42 {{- if .Values.backup.s3 }}
43 {{- if .Values.backup.s3.credentialsSecret }}
44 - name: aws-credentials-secret
46 secretName: {{ .Values.backup.s3.credentialsSecret | quote }}
49 serviceAccountName: {{ include "influxdb.serviceAccountName" . }}
51 - name: influxdb-backup
52 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
62 -host {{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}.svc:{{ .Values.config.rpc.bind_address | default 8088 }} \
63 -portable /backup/"$(date +%Y%m%d%H%M%S)"
65 {{- toYaml .Values.backup.resources | nindent 14 }}
67 {{- if .Values.backup.gcs }}
69 image: google/cloud-sdk:alpine
76 if [ -n "$KEY_FILE" ]; then
77 gcloud auth activate-service-account --key-file $KEY_FILE
79 gsutil -m cp -r /backup/* "$DST_URL"
84 {{- if .Values.backup.gcs.serviceAccountSecretKey}}
85 - name: google-cloud-key
86 mountPath: /var/secrets/google/
90 value: {{ .Values.backup.gcs.destination}}
91 {{- if .Values.backup.gcs.serviceAccountSecretKey}}
93 value: /var/secrets/google/{{ .Values.backup.gcs.serviceAccountSecretKey }}
96 {{- toYaml .Values.backup.resources | nindent 14 }}
98 {{- if .Values.backup.azure }}
100 image: microsoft/azure-cli
107 az storage container create --name "$DST_CONTAINER"
108 az storage blob upload-batch --destination "$DST_CONTAINER" --destination-path "$DST_PATH" --source "$SRC_URL"
116 - name: DST_CONTAINER
117 value: {{ .Values.backup.azure.destination_container }}
119 value: {{ .Values.backup.azure.destination_path }}
120 - name: AZURE_STORAGE_CONNECTION_STRING
123 name: {{ .Values.backup.azure.storageAccountSecret }}
124 key: connection-string
126 {{- toYaml .Values.backup.resources | nindent 14 }}
128 {{- if .Values.backup.s3 }}
130 image: amazon/aws-cli
137 aws {{- if .Values.backup.s3.endpointUrl }} --endpoint-url={{ .Values.backup.s3.endpointUrl }} {{- end }} s3 cp --recursive "$SRC_URL" "$DST_URL"
142 {{- if .Values.backup.s3.credentialsSecret}}
143 - name: aws-credentials-secret
144 mountPath: /var/secrets/aws/
147 - name: AWS_CONFIG_FILE
148 value: /var/secrets/aws/credentials
152 value: {{ .Values.backup.s3.destination }}
154 {{- toYaml .Values.backup.resources | nindent 14 }}