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 <[email protected]>
  • Loading branch information
kjdelisle authored and kevin-delisle-peakpower committed May 15, 2024
1 parent 0468ca0 commit b05670b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 15 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.12
version: 6.1.0
12 changes: 10 additions & 2 deletions 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 Expand Up @@ -604,4 +612,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
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
27 changes: 17 additions & 10 deletions bitnami/influxdb/templates/pvc-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.backup.enabled .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
{{-
/*
Prefer .Values.backup.persistence, but fall back to .Values.persistence if not present.
*/
-}}
{{- if .Values.backup.enabled }}
{{ $persistence := coalesce .Values.backup.persistence .Values.persistence }}
{{ if and $persistence.enabled (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 }}
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" . ) }}
{{- 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 .Values.persistence.accessModes }}
{{- range $persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- include "common.storage.class" ( dict "persistence" .Values.persistence "global" $) | nindent 2 }}
storage: {{ $persistence.size | quote }}
{{- include "common.storage.class" ( dict "persistence" $persistence "global" $) | nindent 2 }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions bitnami/influxdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,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: false
## @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 b05670b

Please sign in to comment.