Unverified Commit a8103183 authored by Naseem's avatar Naseem Committed by GitHub

feat: add option to use PVC for backups -- thanks monotek (#94)

* feat: add option to use PVC for backups -- thanks monotek Signed-off-by: 's avatarNaseem <naseem@transit.app> * break up backup command into multi-line for readability Signed-off-by: 's avatarNaseem <naseem@transit.app> * fix: backup pvc condition Signed-off-by: 's avatarNaseem <naseem@transit.app> * add ephemeral storage request for backup and add note on backup storage in docs Signed-off-by: 's avatarNaseem <naseem@transit.app>
parent b3197cc4
apiVersion: v1
name: influxdb
version: 4.4.12
version: 4.6.0
appVersion: 1.7.10
description: Scalable datastore for metrics, events, and real-time analytics.
keywords:
......
......@@ -104,6 +104,12 @@ The following table lists configurable parameters, their descriptions, and their
| backup.schedule | Schedule to run jobs in cron format | `0 0 * * *` |
| backup.annotations | Annotations for backup cronjob | {} |
| backup.podAnnotations | Annotations for backup cronjob pods | {} |
| backup.persistence.enabled | Boolean to enable and disable persistance | false |
| backup.persistence.storageClass | If set to "-", storageClassName: "", which disables dynamic provisioning. If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. (gp2 on AWS, standard on GKE, AWS & OpenStack | |
| backup.persistence.annotations | Annotations for volumeClaimTemplates | nil |
| backup.persistence.accessMode | Access mode for the volume | ReadWriteOnce |
| backup.persistence.size | Storage size | 8Gi |
| backup.resources | Resources requests and limits for `backup` pods | `ephemeral-storage: 8Gi` |
To configure the chart, do either of the following:
......@@ -199,6 +205,18 @@ When enabled, the[`backup-cronjob`](./templates/backup-cronjob.yaml) runs on the
kubectl create job --from=cronjobs/influxdb-backup influx-backup-$(date +%Y%m%d%H%M%S)
```
#### Backup Storage
The backup process consists of an init-container that writes the backup to a
local volume, which is by default an `emptyDir`, shared to the runtime container
which uploads the backup to the configured object store.
In order to avoid filling the node's disk space, it is recommended to set a sufficient
`ephemeral-storage` request or enable persistence, which allocates a PVC.
Furthermore, if no object store provider is available, one can simply use the
PVC as the final storage destination when `persistence` is enabled.
### Restores
It is up to the end user to configure their own one-off restore jobs. Below is just an example, which assumes that the backups are stored in GCS and that all dbs in the backup already exist and should be restored. It is to be used as a reference only; configure the init-container and the command and of the `influxdb-restore` container as well as both containers' resources to suit your needs.
......
......@@ -25,7 +25,12 @@ spec:
restartPolicy: OnFailure
volumes:
- name: backup
{{- if .Values.backup.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "influxdb.fullname" . }}-backup
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.backup.gcs }}
{{- if .Values.backup.gcs.serviceAccountSecret }}
- name: google-cloud-key
......@@ -45,7 +50,11 @@ spec:
args:
- '-c'
- |
influxd backup -host {{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}.svc:{{ .Values.config.rpc.bind_address | default 8088 }} -portable /backup/$(date +%Y%m%d%H%M%S)
influxd backup \
-host {{ include "influxdb.fullname" . }}.{{ .Release.Namespace }}.svc:{{ .Values.config.rpc.bind_address | default 8088 }} \
-portable /backup/"$(date +%Y%m%d%H%M%S)"
resources:
{{- toYaml .Values.backup.resources | nindent 14 }}
containers:
{{- if .Values.backup.gcs }}
- name: gsutil-cp
......@@ -73,6 +82,8 @@ spec:
- name: KEY_FILE
value: /var/secrets/google/{{ .Values.backup.gcs.serviceAccountSecretKey }}
{{- end }}
resources:
{{- toYaml .Values.backup.resources | nindent 14 }}
{{- end }}
{{- if .Values.backup.azure }}
- name: azure-cli
......@@ -99,5 +110,7 @@ spec:
secretKeyRef:
name: {{ .Values.backup.azure.storageAccountSecret }}
key: connection-string
resources:
{{- toYaml .Values.backup.resources | nindent 14 }}
{{- end }}
{{- end }}
{{- if and .Values.backup.enabled .Values.backup.persistence.enabled }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "influxdb.fullname" . }}-backup
labels:
{{- include "influxdb.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.backup.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.backup.persistence.size | quote }}
{{- if .Values.backup.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.backup.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.backup.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
......@@ -242,6 +242,30 @@ initScripts:
backup:
enabled: false
## By default emptyDir is used as a transitory volume before uploading to object store.
## As such, ensure that a sufficient ephemeral storage request is set to prevent node disk filling completely.
resources:
requests:
# memory: 512Mi
# cpu: 2
ephemeral-storage: "8Gi"
# limits:
# memory: 1Gi
# cpu: 4
# ephemeral-storage: "16Gi"
## If backup destination is PVC, or want to use intermediate PVC before uploading to object store.
persistence:
enabled: false
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
annotations:
accessMode: ReadWriteOnce
size: 8Gi
schedule: "0 0 * * *"
annotations: {}
podAnnotations: {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment