From cea744e9a7c20ffce910bbaac1c6bd9777ac4aab Mon Sep 17 00:00:00 2001 From: SakaSun Date: Fri, 20 Dec 2019 02:12:15 -0300 Subject: [PATCH] [Issue 5857][Helm Chart] - Support to existing Storage Class with StorageClassName (#5860) Fixes #5857 ### Motivation With current aproach for specifying storage class in persistent volume claim it's not possible to customize the provisioner parameters. If the property 'storageClass' is declared the chart always create a new storage class with hardcoded parameters. ### Modifications A property 'storageClassName' was added to support an existent storage class. ### Verifying this change This change is a trivial rework / code cleanup without any test coverage. --- pulsar/templates/bookkeeper-statefulset.yaml | 8 +++-- pulsar/templates/prometheus-pvc.yaml | 4 ++- pulsar/templates/zookeeper-statefulset.yaml | 4 ++- pulsar/values.yaml | 32 +++++++++++++++----- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/pulsar/templates/bookkeeper-statefulset.yaml b/pulsar/templates/bookkeeper-statefulset.yaml index b48c729..eb2597d 100644 --- a/pulsar/templates/bookkeeper-statefulset.yaml +++ b/pulsar/templates/bookkeeper-statefulset.yaml @@ -143,7 +143,9 @@ spec: resources: requests: storage: {{ .Values.bookkeeper.volumes.journal.size }} - {{- if .Values.bookkeeper.volumes.journal.storageClass }} + {{- if .Values.bookkeeper.volumes.journal.storageClassName }} + storageClassName: "{{ .Values.bookkeeper.volumes.journal.storageClassName }}" + {{- else if .Values.bookkeeper.volumes.journal.storageClass }} storageClassName: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.journal.name }}" {{- end }} - metadata: @@ -153,7 +155,9 @@ spec: resources: requests: storage: {{ .Values.bookkeeper.volumes.ledgers.size }} - {{- if .Values.bookkeeper.volumes.ledgers.storageClass }} + {{- if .Values.bookkeeper.volumes.ledgers.storageClassName }} + storageClassName: "{{ .Values.bookkeeper.volumes.ledgers.storageClassName }}" + {{- else if .Values.bookkeeper.volumes.ledgers.storageClass }} storageClassName: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.ledgers.name }}" {{- end }} {{- end }} diff --git a/pulsar/templates/prometheus-pvc.yaml b/pulsar/templates/prometheus-pvc.yaml index 3cbab53..bccb773 100644 --- a/pulsar/templates/prometheus-pvc.yaml +++ b/pulsar/templates/prometheus-pvc.yaml @@ -29,7 +29,9 @@ spec: requests: storage: {{ .Values.prometheus.volumes.data.size }} accessModes: [ "ReadWriteOnce" ] -{{- if .Values.prometheus.volumes.data.storageClass }} +{{- if .Values.prometheus.volumes.data.storageClassName }} + storageClassName: "{{ .Values.prometheus.volumes.data.storageClassName }}" +{{- else if .Values.prometheus.volumes.data.storageClass }} storageClassName: "{{ template "pulsar.fullname" . }}-{{ .Values.prometheus.component }}-{{ .Values.prometheus.volumes.data.name }}" {{- end }} {{- end }} diff --git a/pulsar/templates/zookeeper-statefulset.yaml b/pulsar/templates/zookeeper-statefulset.yaml index b92fed7..fda52fe 100644 --- a/pulsar/templates/zookeeper-statefulset.yaml +++ b/pulsar/templates/zookeeper-statefulset.yaml @@ -136,7 +136,9 @@ spec: resources: requests: storage: {{ .Values.zookeeper.volumes.data.size }} - {{- if .Values.zookeeper.volumes.data.storageClass }} + {{- if .Values.zookeeper.volumes.data.storageClassName }} + storageClassName: "{{ .Values.zookeeper.volumes.data.storageClassName }}" + {{- else if .Values.zookeeper.volumes.data.storageClass }} storageClassName: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ .Values.zookeeper.volumes.data.name }}" {{- end }} {{- end }} diff --git a/pulsar/values.yaml b/pulsar/values.yaml index 69b3ccf..f2ae864 100644 --- a/pulsar/values.yaml +++ b/pulsar/values.yaml @@ -80,8 +80,12 @@ zookeeper: data: name: data size: 20Gi - ## If the storage class is left undefined when using persistence - ## the default storage class for the cluster will be used. + ## If you already have an existent storage class and want to reuse it, you can specify its name with the option below + ## + # storageClassName: existent-storage-class + # + ## Instead if you want to create a new storage class define it below + ## If left undefined no storage class will be defined along with PVC ## # storageClass: # type: pd-ssd @@ -146,8 +150,12 @@ bookkeeper: journal: name: journal size: 50Gi - ## If the storage class is left undefined when using persistence - ## the default storage class for the cluster will be used. + ## If you already have an existent storage class and want to reuse it, you can specify its name with the option below + ## + # storageClassName: existent-storage-class + # + ## Instead if you want to create a new storage class define it below + ## If left undefined no storage class will be defined along with PVC ## # storageClass: # type: pd-ssd @@ -156,8 +164,12 @@ bookkeeper: ledgers: name: ledgers size: 50Gi - ## If the storage class is left undefined when using persistence - ## the default storage class for the cluster will be used. + ## If you already have an existent storage class and want to reuse it, you can specify its name with the option below + ## + # storageClassName: existent-storage-class + # + ## Instead if you want to create a new storage class define it below + ## If left undefined no storage class will be defined along with PVC ## # storageClass: # type: pd-ssd @@ -387,8 +399,12 @@ prometheus: data: name: data size: 50Gi - ## If the storage class is left undefined when using persistence - ## the default storage class for the cluster will be used. + ## If you already have an existent storage class and want to reuse it, you can specify its name with the option below + ## + # storageClassName: existent-storage-class + # + ## Instead if you want to create a new storage class define it below + ## If left undefined no storage class will be defined along with PVC ## # storageClass: # type: pd-standard