From b05670b4f44eb76bddee22ba97e05e85d168aafd Mon Sep 17 00:00:00 2001 From: Kevin Delisle Date: Tue, 12 Dec 2023 17:11:10 -0500 Subject: [PATCH] [bitnami/influxdb] Allow separate persistence cfg for backups 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 --- bitnami/influxdb/Chart.yaml | 2 +- bitnami/influxdb/README.md | 12 ++++++-- .../influxdb/templates/cronjob-backup.yaml | 7 +++-- bitnami/influxdb/templates/pvc-backup.yaml | 27 ++++++++++------- bitnami/influxdb/values.yaml | 30 +++++++++++++++++++ 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/bitnami/influxdb/Chart.yaml b/bitnami/influxdb/Chart.yaml index 0733fab565508d..8b82991aefc509 100644 --- a/bitnami/influxdb/Chart.yaml +++ b/bitnami/influxdb/Chart.yaml @@ -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 diff --git a/bitnami/influxdb/README.md b/bitnami/influxdb/README.md index 0ae1a8681416c1..3b9e4cccb20249 100644 --- a/bitnami/influxdb/README.md +++ b/bitnami/influxdb/README.md @@ -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. @@ -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 | `[]` | @@ -377,6 +379,12 @@ There are K8s distribution, such as OpenShift, where you can dynamically define | `backup.enabled` | Enable InfluxDB™ 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 | `{}` | @@ -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. \ No newline at end of file +limitations under the License. diff --git a/bitnami/influxdb/templates/cronjob-backup.yaml b/bitnami/influxdb/templates/cronjob-backup.yaml index 71b416a12d47db..a27608b8c616e3 100644 --- a/bitnami/influxdb/templates/cronjob-backup.yaml +++ b/bitnami/influxdb/templates/cronjob-backup.yaml @@ -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 }} diff --git a/bitnami/influxdb/templates/pvc-backup.yaml b/bitnami/influxdb/templates/pvc-backup.yaml index b5c73780de8630..c27b8d392f88f9 100644 --- a/bitnami/influxdb/templates/pvc-backup.yaml +++ b/bitnami/influxdb/templates/pvc-backup.yaml @@ -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 }} diff --git a/bitnami/influxdb/values.yaml b/bitnami/influxdb/values.yaml index c09351d426e9bb..ee7cb8466a9c55 100644 --- a/bitnami/influxdb/values.yaml +++ b/bitnami/influxdb/values.yaml @@ -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: + ## 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™ backups ##