Skip to content

Commit

Permalink
[bitnami/influxdb] Allow separate persistence cfg for backups
Browse files Browse the repository at this point in the history
Add an optional configuration section under backup that allows
the specification of distinct values for persistence.

If this configuration section is not provided, the template will
default to rendering using the existing top-level persistence
configuration section to maintain compatibility.

Signed-off-by: Kevin Delisle <kjdelisle@gmail.com>
  • Loading branch information
kjdelisle authored and kevin-delisle-peakpower committed Mar 20, 2024
1 parent 2fd560d commit f55bf93
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bitnami/influxdb/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ maintainers:
name: influxdb
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/influxdb
version: 6.0.3
version: 6.1.0
10 changes: 9 additions & 1 deletion bitnami/influxdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ As an alternative, you can use of the preset configurations for pod affinity, po
The data is persisted by default using PVC(s). You can disable the persistence setting the `persistence.enabled` parameter to `false`.
A default `StorageClass` is needed in the Kubernetes cluster to dynamically provision the volumes. Specify another StorageClass in the `persistence.storageClass` or set `persistence.existingClaim` if you have already existing persistent volumes to use.

If you would like to define persistence settings for a backup volume that differ from the persistence settings for the database volume, you may do so under the `backup.persistence` section of the configuration. If this section is undefined, but `backup.enabled` is set to true, the backup volume will be defined using the `persistence` parameter section.

### Adjust permissions of persistent volume mountpoint

As the images run as non-root by default, it is necessary to adjust the ownership of the persistent volumes so that the containers can write data into it.
Expand Down Expand Up @@ -304,7 +306,7 @@ There are K8s distribution, such as OpenShift, where you can dynamically define
| `ingress.pathType` | Ingress path type | `ImplementationSpecific` |
| `ingress.apiVersion` | Force Ingress API version (automatically detected if not set) | `""` |
| `ingress.hostname` | Default host for the ingress resource (evaluated as template) | `influxdb.local` |
| `ingress.path` | Ingress path*' in order to use this | `/` |
| `ingress.path` | Ingress path\*' in order to use this | `/` |
| `ingress.annotations` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. | `{}` |
| `ingress.extraHosts` | The list of additional hostnames to be covered with this ingress record. | `[]` |
| `ingress.extraPaths` | Additional arbitrary path/backend objects | `[]` |
Expand Down Expand Up @@ -377,6 +379,12 @@ There are K8s distribution, such as OpenShift, where you can dynamically define
| `backup.enabled` | Enable InfluxDB&trade; backup | `false` |
| `backup.directory` | Directory where backups are stored | `/backups` |
| `backup.retentionDays` | Retention time in days for backups (older backups are deleted) | `10` |
| `backup.persistence.enabled` | Enable data persistence for backup volume | `true` |
| `backup.persistence.existingClaim` | Use a existing PVC which must be created manually before bound | `""` |
| `backup.persistence.storageClass` | Specify the `storageClass` used to provision the volume | `""` |
| `backup.persistence.accessModes` | Access mode of data volume | `["ReadWriteOnce"]` |
| `backup.persistence.size` | Size of data volume | `8Gi` |
| `backup.persistence.annotations` | Persistent Volume Claim annotations | `{}` |
| `backup.cronjob.schedule` | Schedule in Cron format to save snapshots | `0 2 * * *` |
| `backup.cronjob.historyLimit` | Number of successful finished jobs to retain | `1` |
| `backup.cronjob.podAnnotations` | Pod annotations | `{}` |
Expand Down
31 changes: 31 additions & 0 deletions bitnami/influxdb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,34 @@ Get the InfluxDB&trade; initialization scripts secret.
{{- define "influxdb.initdbScriptsSecret" -}}
{{- printf "%s" (tpl .Values.influxdb.initdbScriptsSecret $) -}}
{{- end -}}

{{- /*
Helper template for determining which persistence settings to use for backup PVC.
Allows backwards-compatibility for users that have not defined a backups.persistence dict in their values files.
*/}}
{{- define "influxdb.backup.pvc" }}
{{- $ := index . 0 }}
{{- $persistence := index . 1 }}
{{- if not $persistence.existingClaim -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" $ }}-backups
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: influxdb
{{- if or $persistence.annotations $.Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $persistence.annotations $.Values.commonAnnotations ) "context" $ ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
accessModes:
{{- range $persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ $persistence.size | quote }}
{{- include "common.storage.class" ( dict "persistence" $persistence "global" $) | nindent 2 }}
{{- end }}
{{- end }}
7 changes: 5 additions & 2 deletions bitnami/influxdb/templates/cronjob-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ spec:
{{- end }}
{{- end }}
- name: {{ include "common.names.fullname" . }}-backups
{{- if .Values.persistence.enabled }}
{{- if .Values.backup.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "common.names.fullname" . }}-backups
claimName: {{ default (printf "%s-%s" (include "common.names.fullname" . ) "backups") .Values.backup.persistence.existingClaim }}
{{- else if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ default (printf "%s-%s" (include "common.names.fullname" . ) "backups") .Values.persistence.existingClaim }}
{{- else }}
emptyDir: {}
{{- end }}
Expand Down
33 changes: 12 additions & 21 deletions bitnami/influxdb/templates/pvc-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,17 @@
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.backup.enabled .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" . }}-backups
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: influxdb
{{- if or .Values.persistence.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.persistence.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{-
/*
Prefer .Values.backup.persistence, but fall back to .Values.persistence if not present.
*/
-}}
{{- if .Values.backup.enabled }}
{{- if and .Values.backup.persistence .Values.backup.persistence.enabled }}
{{- include "influxdb.backup.pvc" (list $ .Values.backup.persistence) }}
{{- else if .Values.persistence.enabled }}
{{- include "influxdb.backup.pvc" (list $ .Values.persistence) }}
{{- else }}
{{/* Should backups be supported without any persistence? */}}
{{- end }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- include "common.storage.class" ( dict "persistence" .Values.persistence "global" $) | nindent 2 }}
{{- end }}
30 changes: 30 additions & 0 deletions bitnami/influxdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,36 @@ backup:
## @param backup.retentionDays Retention time in days for backups (older backups are deleted)
##
retentionDays: 10

## Persistence parameters
##
persistence:
## @param backup.persistence.enabled Enable data persistence for backup volume
##
enabled: true
## @param backup.persistence.existingClaim Use a existing PVC which must be created manually before bound
## If defined, PVC must be created manually before volume will be bound
## The value is evaluated as a template
##
existingClaim: ""
## @param backup.persistence.storageClass Specify the `storageClass` used to provision the volume
## 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.
##
storageClass: ""
## @param backup.persistence.accessModes Access mode of data volume
##
accessModes:
- ReadWriteOnce
## @param backup.persistence.size Size of data volume
##
size: 8Gi
## @param backup.persistence.annotations Persistent Volume Claim annotations
##
annotations: {}

## Cronjob configuration
## This cronjob is used to create InfluxDB&trade; backups
##
Expand Down

0 comments on commit f55bf93

Please sign in to comment.