From 2199a18599d49dbfc8d98c7d23159f0271c0ef2d Mon Sep 17 00:00:00 2001 From: juan131 Date: Mon, 3 Jun 2019 12:14:06 +0200 Subject: [PATCH] Support 'existing claims' for snapshotter pvc --- bitnami/etcd/README.md | 3 +++ bitnami/etcd/templates/_helpers.tpl | 13 +++++++++++++ bitnami/etcd/templates/cronjob.yaml | 2 +- bitnami/etcd/templates/snapshot-pvc.yaml | 2 +- bitnami/etcd/templates/statefulset.yaml | 2 +- bitnami/etcd/values-production.yaml | 6 ++++++ bitnami/etcd/values.yaml | 6 ++++++ 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/bitnami/etcd/README.md b/bitnami/etcd/README.md index 426e4ebc3..18bd732ab 100644 --- a/bitnami/etcd/README.md +++ b/bitnami/etcd/README.md @@ -115,6 +115,7 @@ The following tables lists the configurable parameters of the etcd chart and the | `disasterRecovery.cronjob.schedule` | Schedule in Cron format to save snapshots | `*/30 * * * *` | | `disasterRecovery.cronjob.historyLimit` | Number of successful finished jobs to retain | `1` | | `disasterRecovery.cronjob.podAnnotations` | Pod annotations for cronjob pods | `{}` | +| `disasterRecovery.pvc.existingClaim` | Provide an existing `PersistentVolumeClaim`, the value is evaluated as a template. | `nil` | | `disasterRecovery.pvc.size` | PVC Storage Request | `2Gi` | | `disasterRecovery.pvc.storageClassName` | Storage Class for snapshots volume | `nfs` | @@ -236,6 +237,8 @@ $ helm upgrade my-release bitnami/etcd \ --set statefulset.replicaCount=5 ``` +> **Note**: Scaling the statefulset with `kubectl scale ...` command is highly discouraged. Use `helm upgrade ...` for horizontal scaling so you ensure all the environment variables used to configure the ectd cluster are properly updated. + ## Enable security for etcd ### Configure RBAC diff --git a/bitnami/etcd/templates/_helpers.tpl b/bitnami/etcd/templates/_helpers.tpl index a4fbc36f3..dbb910b88 100644 --- a/bitnami/etcd/templates/_helpers.tpl +++ b/bitnami/etcd/templates/_helpers.tpl @@ -78,6 +78,19 @@ Return the proper etcd data dir {{- end -}} {{- end -}} +{{/* +Return the proper Disaster Recovery PVC name +*/}} +{{- define "etcd.disasterRecovery.pvc.name" -}} +{{- if .Values.disasterRecovery.pvc.existingClaim -}} +{{- with .Values.disasterRecovery.pvc.existingClaim -}} +{{ tpl . $ }} +{{- end -}} +{{- else -}} +{{ template "etcd.fullname" . }}-snapshotter +{{- end -}} +{{- end -}} + {{/* Return the proper etcdctl authentication options */}} diff --git a/bitnami/etcd/templates/cronjob.yaml b/bitnami/etcd/templates/cronjob.yaml index aee49e356..5b16a9391 100644 --- a/bitnami/etcd/templates/cronjob.yaml +++ b/bitnami/etcd/templates/cronjob.yaml @@ -64,5 +64,5 @@ spec: defaultMode: 0755 - name: snapshot-volume persistentVolumeClaim: - claimName: {{ template "etcd.fullname" . }}-snapshotter + claimName: {{ template "etcd.disasterRecovery.pvc.name" . }} {{- end }} diff --git a/bitnami/etcd/templates/snapshot-pvc.yaml b/bitnami/etcd/templates/snapshot-pvc.yaml index 18ea2ea71..635d8643b 100644 --- a/bitnami/etcd/templates/snapshot-pvc.yaml +++ b/bitnami/etcd/templates/snapshot-pvc.yaml @@ -1,4 +1,4 @@ -{{- if .Values.disasterRecovery.enabled -}} +{{- if and .Values.disasterRecovery.enabled (not .Values.disasterRecovery.pvc.existingClaim) -}} kind: PersistentVolumeClaim apiVersion: v1 metadata: diff --git a/bitnami/etcd/templates/statefulset.yaml b/bitnami/etcd/templates/statefulset.yaml index f9f4ce323..9174299ff 100644 --- a/bitnami/etcd/templates/statefulset.yaml +++ b/bitnami/etcd/templates/statefulset.yaml @@ -266,7 +266,7 @@ spec: {{- if .Values.disasterRecovery.enabled }} - name: snapshot-volume persistentVolumeClaim: - claimName: {{ template "etcd.fullname" . }}-snapshotter + claimName: {{ template "etcd.disasterRecovery.pvc.name" . }} {{- end }} {{- if .Values.configFileConfigMap }} - name: etcd-config diff --git a/bitnami/etcd/values-production.yaml b/bitnami/etcd/values-production.yaml index 81995edf9..31e7c18ff 100644 --- a/bitnami/etcd/values-production.yaml +++ b/bitnami/etcd/values-production.yaml @@ -238,6 +238,12 @@ disasterRecovery: ## # resources: pvc: + ## A manually managed Persistent Volume and Claim + ## If defined, PVC must be created manually before volume will be bound + ## The value is evaluated as a template, so, for example, the name can depend on .Release or .Chart + ## + # existingClaim: + ## PVC Storage Request ## size: 2Gi diff --git a/bitnami/etcd/values.yaml b/bitnami/etcd/values.yaml index e5917880c..d6c03e078 100644 --- a/bitnami/etcd/values.yaml +++ b/bitnami/etcd/values.yaml @@ -238,6 +238,12 @@ disasterRecovery: ## # resources: pvc: + ## A manually managed Persistent Volume and Claim + ## If defined, PVC must be created manually before volume will be bound + ## The value is evaluated as a template, so, for example, the name can depend on .Release or .Chart + ## + # existingClaim: + ## PVC Storage Request ## size: 2Gi