Skip to content

Commit

Permalink
[influxdb] fix backup job (#462)
Browse files Browse the repository at this point in the history
* fix optional parameter handling

* add backup job node selector support

* bump version

* Fix indenting

Co-authored-by: Pavel Závora <[email protected]>

* Fixed indenting more
  • Loading branch information
alespour authored May 9, 2022
1 parent 3219dd5 commit 5fb994f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion charts/influxdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: influxdb
version: 4.11.0
version: 4.12.0
appVersion: 1.8.10
description: Scalable datastore for metrics, events, and real-time analytics.
keywords:
Expand Down
7 changes: 5 additions & 2 deletions charts/influxdb/files/backup-retention-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ set -e
# Sanity check to avoid removing all backups.
[[ "$DAYS_TO_RETAIN" -lt 1 ]] && DAYS_TO_RETAIN=1

# Prepare endpoint-url argument
[[ -z "$S3_ENDPOINT" ]] && endpoint_arg="" || endpoint_arg="--endpoint-url ${S3_ENDPOINT}"

function get_records {
before_date="$1"

aws s3api list-objects \
--bucket ${S3_BUCKET} \
--endpoint-url ${S3_ENDPOINT} \
${endpoint_arg} \
--query "Contents[?LastModified<='${before_date}'][].{Key: Key}"
}

Expand Down Expand Up @@ -56,7 +59,7 @@ function remove_old_backups {

for path in "${del_paths[@]::${num_to_delete}}"; do
aws s3 rm "s3://${S3_BUCKET}/${path}" \
--endpoint-url "${S3_ENDPOINT}"
${endpoint_arg}
done
}

Expand Down
4 changes: 4 additions & 0 deletions charts/influxdb/templates/backup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
{{- include "influxdb.selectorLabels" . | nindent 12 }}
spec:
restartPolicy: OnFailure
{{- with .Values.backup.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: backup
{{- if .Values.backup.persistence.enabled }}
Expand Down
21 changes: 11 additions & 10 deletions charts/influxdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,31 +262,32 @@ backup:
startingDeadlineSeconds: ""
annotations: {}
podAnnotations: {}
nodeSelector: {}

## Google Cloud Storage
# gcs:
# serviceAccountSecret: influxdb-backup-key
# serviceAccountSecretKey: key.json
# destination: gs://bucket/influxdb
# serviceAccountSecret: influxdb-backup-key
# serviceAccountSecretKey: key.json
# destination: gs://bucket/influxdb

## Azure
## Secret is expected to have connection string stored in `connection-string` field
## Existing container will be used or private one withing storage account will be created.
# azure:
# storageAccountSecret: influxdb-backup-azure-key
# destination_container: influxdb-container
# destination_path: ""
# storageAccountSecret: influxdb-backup-azure-key
# destination_container: influxdb-container
# destination_path: ""

## Amazon S3 or compatible
## Secret is expected to have AWS (or compatible) credentials stored in `credentials` field.
## Please look at https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-where
## for the credentials format.
## The bucket should already exist.
# s3:
# credentialsSecret: aws-credentials-secret
# destination: s3://bucket/path
# ## Optional. Specify if you're using an alternate S3 endpoint.
# # endpointUrl: ""
# credentialsSecret: aws-credentials-secret
# destination: s3://bucket/path
## Optional. Specify if you're using an alternate S3 endpoint.
# endpointUrl: ""

backupRetention:
enabled: false
Expand Down

0 comments on commit 5fb994f

Please sign in to comment.