From 343ce0527de1d82a4e3582e813ae7645866524a1 Mon Sep 17 00:00:00 2001 From: Claudio Vellage Date: Thu, 20 Oct 2022 20:46:23 +0200 Subject: [PATCH] Allow to use selectors with volumeClaimTemplates (#286) * Allow to use selectors with volumeClaimTemplates * Fixed naming inconsistency, added null value Co-authored-by: Claudio Vellage Co-authored-by: Michael Marshall ### Motivation Currently it's not possible to use selectors with volumeClaimTemplates which makes it hard/impossible to bind statically provisioned PVs. ### Modifications Added (optional) selectors to `volumeClaimTemplates` and documented in values file. ### Verifying this change - [ ] Make sure that the change passes the CI checks. --- .../templates/bookkeeper-statefulset.yaml | 20 +++++++++++++++++++ .../templates/zookeeper-statefulset.yaml | 4 ++++ charts/pulsar/values.yaml | 14 +++++++++++++ 3 files changed, 38 insertions(+) diff --git a/charts/pulsar/templates/bookkeeper-statefulset.yaml b/charts/pulsar/templates/bookkeeper-statefulset.yaml index b3bf4d8..e1b3948 100644 --- a/charts/pulsar/templates/bookkeeper-statefulset.yaml +++ b/charts/pulsar/templates/bookkeeper-statefulset.yaml @@ -248,6 +248,10 @@ spec: {{- else if and .Values.volumes.local_storage .Values.bookkeeper.volumes.common.local_storage }} storageClassName: "local-storage" {{- end }} + {{- with .Values.bookkeeper.volumes.common.selector }} + selector: + {{- toYaml . | nindent 10 }} + {{- end }} {{- else }} {{- if .Values.bookkeeper.volumes.journal.useMultiVolumes }} {{- $fullname := include "pulsar.fullname" . -}} @@ -263,6 +267,10 @@ spec: {{- if .storageClassName }} storageClassName: "{{ .storageClassName }}" {{- end }} + {{- with .Values.bookkeeper.volumes.journal.selector }} + selector: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- else }} - metadata: @@ -279,6 +287,10 @@ spec: {{- else if and .Values.volumes.local_storage .Values.bookkeeper.volumes.journal.local_storage }} storageClassName: "local-storage" {{- end }} + {{- with .Values.bookkeeper.volumes.journal.selector }} + selector: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- if .Values.bookkeeper.volumes.ledgers.useMultiVolumes }} {{- $fullname := include "pulsar.fullname" . -}} @@ -294,6 +306,10 @@ spec: {{- if .storageClassName }} storageClassName: "{{ .storageClassName }}" {{- end }} + {{- with .Values.bookkeeper.volumes.ledgers.selector }} + selector: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- else }} - metadata: @@ -310,6 +326,10 @@ spec: {{- else if and .Values.volumes.local_storage .Values.bookkeeper.volumes.ledgers.local_storage }} storageClassName: "local-storage" {{- end }} + {{- with .Values.bookkeeper.volumes.ledgers.selector }} + selector: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/charts/pulsar/templates/zookeeper-statefulset.yaml b/charts/pulsar/templates/zookeeper-statefulset.yaml index 7fb3002..ef8f9c3 100644 --- a/charts/pulsar/templates/zookeeper-statefulset.yaml +++ b/charts/pulsar/templates/zookeeper-statefulset.yaml @@ -268,5 +268,9 @@ spec: {{- else if and .Values.volumes.local_storage .Values.zookeeper.volumes.data.local_storage }} storageClassName: "local-storage" {{- end }} + {{- with .Values.zookeeper.volumes.data.selector }} + selector: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- end }} diff --git a/charts/pulsar/values.yaml b/charts/pulsar/values.yaml index 9d7df5e..c84b5f4 100644 --- a/charts/pulsar/values.yaml +++ b/charts/pulsar/values.yaml @@ -367,6 +367,11 @@ zookeeper: # type: pd-ssd # fsType: xfs # provisioner: kubernetes.io/gce-pd + ## If you want to bind static persistent volumes via selectors, e.g.: + # selector: + # matchLabels: + # app: pulsar-zookeeper + selector: {} # External zookeeper server list in case of global-zk list to create zk cluster across zk deployed on different clusters/namespaces # Example value: "us-east1-pulsar-zookeeper-0.us-east1-pulsar-zookeeper.us-east1.svc.cluster.local:2888:3888,us-east1-pulsar-zookeeper-1.us-east1-pulsar-zookeeper.us-east1.svc.cluster.local:2888:3888,us-east1-pulsar-zookeeper-2.us-east1-pulsar-zookeeper.us-east1.svc.cluster.local:2888:3888,us-west1-pulsar-zookeeper-0.us-west1-pulsar-zookeeper.us-west1.svc.cluster.local:2888:3888,us-west1-pulsar-zookeeper-1.us-west1-pulsar-zookeeper.us-west1.svc.cluster.local:2888:3888,us-west1-pulsar-zookeeper-2.us-west1-pulsar-zookeeper.us-west1.svc.cluster.local:2888:3888" externalZookeeperServerList: "" @@ -501,6 +506,11 @@ bookkeeper: # type: pd-ssd # fsType: xfs # provisioner: kubernetes.io/gce-pd + ## If you want to bind static persistent volumes via selectors, e.g.: + # selector: + # matchLabels: + # app: pulsar-bookkeeper-journal + selector: {} useMultiVolumes: false multiVolumes: - name: journal0 @@ -518,6 +528,8 @@ bookkeeper: # storageClassName: # storageClass: # ... + # selector: + # ... useMultiVolumes: false multiVolumes: - name: ledgers0 @@ -538,6 +550,8 @@ bookkeeper: # storageClassName: # storageClass: ## this is common too # ... + # selector: + # ... ## Bookkeeper configmap ## templates/bookkeeper-configmap.yaml