[DMaaP] Use global storage templates for PVC

OOM has now templates in order to create the needed PVC, using:

* a PV with a specific class when using a common nfs mount path between
nodes (sames as today use) --> is the default behavior today
* or a storage class if we want to use dynamic PV.
  On this case, we use (in order of priority):
  - persistence.storageClassOverride if set on the chart
  - global.persistence.storageClass if set globally
  - persistence.storageClass if set on the chart

I've also split the 3 PV from dr-node into 3 files and used range so the
number of PV is the same as number of PODs.

Change-Id: I46b4e62042ea8330bef8cdc1561fa8bbf3f25d12
Issue-ID: OOM-1227
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
diff --git a/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-aaf.yaml b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-aaf.yaml
new file mode 100644
index 0000000..9b71b93
--- /dev/null
+++ b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-aaf.yaml
@@ -0,0 +1,54 @@
+{{/*
+  # ============LICENSE_START=======================================================
+  #  Copyright (C) 2019 Nordix Foundation.
+  # ================================================================================
+  # Licensed under the Apache License, Version 2.0 (the "License");
+  # you may not use this file except in compliance with the License.
+  # You may obtain a copy of the License at
+  #
+  #      http://www.apache.org/licenses/LICENSE-2.0
+  #
+  # 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.
+  #
+  # SPDX-License-Identifier: Apache-2.0
+  # ============LICENSE_END=========================================================
+*/}}
+
+
+{{- if .Values.global.aafEnabled }}
+{{- $global := . }}
+{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
+{{- if eq "True" (include "common.needPV" .) -}}
+{{- range $i := until (int $global.Values.replicaCount)}}
+---
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+  name: {{ include "common.fullname" $global }}-aaf-props-{{ $i }}
+  namespace: {{ include "common.namespace" $global }}
+  labels:
+    app: {{ include "common.name" $global }}
+    chart: "{{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}"
+    release: "{{ $global.Release.Name }}"
+    heritage: "{{ $global.Release.Service }}"
+    name: {{ include "common.fullname" $global }}-aaf-props
+spec:
+  capacity:
+    storage: {{ $global.Values.persistence.aafCredsSize }}
+  accessModes:
+    - {{ $global.Values.persistence.accessMode }}
+  storageClassName: "{{ include "common.fullname" $global }}-data-aaf-props"
+  persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
+  hostPath:
+    path: {{ $global.Values.global.persistence.mountPath | default $global.Values.persistence.mountPath }}/{{ $global.Release.Name }}/{{ $global.Values.persistence.aafCredsMountSubPath }}-{{$i}}
+{{if ne $i (int $global.Values.replicaCount) }}
+---
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
diff --git a/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-event.yaml b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-event.yaml
new file mode 100644
index 0000000..1dd7302
--- /dev/null
+++ b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-event.yaml
@@ -0,0 +1,51 @@
+{{/*
+  # ============LICENSE_START=======================================================
+  #  Copyright (C) 2019 Nordix Foundation.
+  # ================================================================================
+  # Licensed under the Apache License, Version 2.0 (the "License");
+  # you may not use this file except in compliance with the License.
+  # You may obtain a copy of the License at
+  #
+  #      http://www.apache.org/licenses/LICENSE-2.0
+  #
+  # 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.
+  #
+  # SPDX-License-Identifier: Apache-2.0
+  # ============LICENSE_END=========================================================
+*/}}
+
+---
+{{- $global := . }}
+{{- if and $global.Values.persistence.enabled (not $global.Values.persistence.existingClaim) }}
+{{- if eq "True" (include "common.needPV" .) -}}
+{{- range $i := until (int $global.Values.replicaCount)}}
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+  name: {{ include "common.fullname" $global }}-event-logs-{{ $i }}
+  namespace: {{ include "common.namespace" $global }}
+  labels:
+    app: {{ include "common.fullname" $global }}
+    chart: "{{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}"
+    release: "{{ $global.Release.Name }}"
+    heritage: "{{ $global.Release.Service }}"
+    name: {{ include "common.fullname" $global }}-event-logs
+spec:
+  capacity:
+    storage: {{ $global.Values.persistence.eventLogSize}}
+  accessModes:
+    - {{ $global.Values.persistence.accessMode }}
+  persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
+  storageClassName: "{{ include "common.fullname" $global }}-data-event-logs"
+  hostPath:
+    path: {{ $global.Values.global.persistence.mountPath | default $global.Values.persistence.mountPath }}/{{ $global.Release.Name }}/{{ $global.Values.persistence.eventLogsMountSubPath }}-{{$i}}
+{{if ne $i (int $global.Values.replicaCount) }}
+---
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
diff --git a/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-spool.yaml b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-spool.yaml
new file mode 100644
index 0000000..5e1c339
--- /dev/null
+++ b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv-spool.yaml
@@ -0,0 +1,50 @@
+{{/*
+  # ============LICENSE_START=======================================================
+  #  Copyright (C) 2019 Nordix Foundation.
+  # ================================================================================
+  # Licensed under the Apache License, Version 2.0 (the "License");
+  # you may not use this file except in compliance with the License.
+  # You may obtain a copy of the License at
+  #
+  #      http://www.apache.org/licenses/LICENSE-2.0
+  #
+  # 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.
+  #
+  # SPDX-License-Identifier: Apache-2.0
+  # ============LICENSE_END=========================================================
+*/}}
+
+{{- $global := . }}
+{{- if and $global.Values.persistence.enabled (not $global.Values.persistence.existingClaim) }}
+{{- if eq "True" (include "common.needPV" .) -}}
+{{- range $i := until (int $global.Values.replicaCount)}}
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+  name: {{ include "common.fullname" $global }}-spool-data-{{$i}}
+  namespace: {{ include "common.namespace" $global }}
+  labels:
+    app: {{ include "common.fullname" $global }}
+    chart: "{{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}"
+    release: "{{ $global.Release.Name }}"
+    heritage: "{{ $global.Release.Service }}"
+    name: {{ include "common.fullname" $global }}-spool-data
+spec:
+  capacity:
+    storage: {{ $global.Values.persistence.spoolSize}}
+  accessModes:
+    - {{ $global.Values.persistence.accessMode }}
+  persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
+  storageClassName: "{{ include "common.fullname" $global }}-data"
+  hostPath:
+    path: {{ $global.Values.global.persistence.mountPath | default $global.Values.persistence.mountPath }}/{{ $global.Release.Name }}/{{ $global.Values.persistence.spoolMountSubPath }}-{{$i}}
+{{if ne $i (int $global.Values.replicaCount) }}
+---
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
diff --git a/kubernetes/dmaap/components/dmaap-dr-node/templates/pv.yaml b/kubernetes/dmaap/components/dmaap-dr-node/templates/pv.yaml
deleted file mode 100644
index 90a9c2c..0000000
--- a/kubernetes/dmaap/components/dmaap-dr-node/templates/pv.yaml
+++ /dev/null
@@ -1,84 +0,0 @@
-{{/*
-  # ============LICENSE_START=======================================================
-  #  Copyright (C) 2019 Nordix Foundation.
-  # ================================================================================
-  # Licensed under the Apache License, Version 2.0 (the "License");
-  # you may not use this file except in compliance with the License.
-  # You may obtain a copy of the License at
-  #
-  #      http://www.apache.org/licenses/LICENSE-2.0
-  #
-  # 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.
-  #
-  # SPDX-License-Identifier: Apache-2.0
-  # ============LICENSE_END=========================================================
-*/}}
-
-kind: PersistentVolume
-apiVersion: v1
-metadata:
-  name: {{ include "common.fullname" . }}-spool-data-pv
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
-    release: "{{ .Release.Name }}"
-    heritage: "{{ .Release.Service }}"
-    name: {{ include "common.fullname" . }}-spool-data-pv
-spec:
-  capacity:
-    storage: {{ .Values.persistence.spoolSize }}
-  accessModes:
-    - {{ .Values.persistence.accessMode }}
-  storageClassName: "{{ include "common.fullname" . }}-spool-data-stcl"
-  persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
-  hostPath:
-    path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.spoolMountSubPath }}
----
-kind: PersistentVolume
-apiVersion: v1
-metadata:
-  name: {{ include "common.fullname" . }}-event-logs-pv
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
-    release: "{{ .Release.Name }}"
-    heritage: "{{ .Release.Service }}"
-    name: {{ include "common.fullname" . }}-event-logs-pv
-spec:
-  capacity:
-    storage: {{ .Values.persistence.eventLogSize }}
-  accessModes:
-    - {{ .Values.persistence.accessMode }}
-  storageClassName: "{{ include "common.fullname" . }}-event-logs-stcl"
-  persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
-  hostPath:
-    path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.eventLogsMountSubPath }}
----
-{{- if .Values.global.aafEnabled }}
-kind: PersistentVolume
-apiVersion: v1
-metadata:
-  name: {{ include "common.fullname" . }}-aaf-props-pv
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
-    release: "{{ .Release.Name }}"
-    heritage: "{{ .Release.Service }}"
-    name: {{ include "common.fullname" . }}-aaf-props-pv
-spec:
-  capacity:
-    storage: {{ .Values.persistence.aafCredsSize }}
-  accessModes:
-    - {{ .Values.persistence.accessMode }}
-  storageClassName: "{{ include "common.fullname" . }}-aaf-props-stcl"
-  persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
-  hostPath:
-    path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.aafCredsMountSubPath }}
-{{ end -}}
\ No newline at end of file
diff --git a/kubernetes/dmaap/components/dmaap-dr-node/templates/statefulset.yaml b/kubernetes/dmaap/components/dmaap-dr-node/templates/statefulset.yaml
index 9dd5f20..7ab2f83 100644
--- a/kubernetes/dmaap/components/dmaap-dr-node/templates/statefulset.yaml
+++ b/kubernetes/dmaap/components/dmaap-dr-node/templates/statefulset.yaml
@@ -51,7 +51,7 @@
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           volumeMounts:
           - mountPath: {{ .Values.persistence.aafCredsPath }}
-            name: {{ include "common.fullname" . }}-aaf-props-pvc
+            name: {{ include "common.fullname" . }}-aaf-props
           command: ["bash","-c","exec /opt/app/aaf_config/bin/agent.sh"]
           env:
           - name: APP_FQI
@@ -82,12 +82,12 @@
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           volumeMounts:
           - mountPath: {{ .Values.persistence.spoolPath }}
-            name: {{ include "common.fullname" . }}-spool-data-pvc
+            name: {{ include "common.fullname" . }}-data
           - mountPath: {{ .Values.persistence.eventLogsPath }}
-            name: {{ include "common.fullname" . }}-event-logs-pvc
+            name: {{ include "common.fullname" . }}-event-logs
         {{- if .Values.global.aafEnabled }}
           - mountPath: {{ .Values.persistence.aafCredsPath }}
-            name: {{ include "common.fullname" . }}-aaf-props-pvc
+            name: {{ include "common.fullname" . }}-aaf-props
         {{- end }}
           command: ["chown","-Rf","1000:1001", "/opt/app/"]
       containers:
@@ -112,12 +112,12 @@
           volumeMounts:
           {{- if .Values.global.aafEnabled }}
           - mountPath: {{ .Values.persistence.aafCredsPath }}
-            name: {{ include "common.fullname" . }}-aaf-props-pvc
+            name: {{ include "common.fullname" . }}-aaf-props
           {{- end }}
           - mountPath: {{ .Values.persistence.spoolPath }}
-            name: {{ include "common.fullname" . }}-spool-data-pvc
+            name: {{ include "common.fullname" . }}-data
           - mountPath: {{ .Values.persistence.eventLogsPath }}
-            name: {{ include "common.fullname" . }}-event-logs-pvc
+            name: {{ include "common.fullname" . }}-event-logs
           - mountPath: /etc/localtime
             name: localtime
             readOnly: false
@@ -171,53 +171,61 @@
             name: {{ include "common.fullname" . }}-dmaap-dr-node-filebeat-configmap
         - name: {{ include "common.fullname" . }}-data-filebeat
           emptyDir: {}
+        - name:  {{ include "common.fullname" . }}-logs
+          emptyDir: {}
+      {{- if not .Values.persistence.enabled }}
         - name:  {{ include "common.fullname" . }}-event-logs-pvc
           emptyDir: {}
-        - name:  {{ include "common.fullname" . }}-logs
+        - name: {{ include "common.fullname" . }}-data
           emptyDir: {}
       {{- if .Values.global.aafEnabled }}
         - name:  {{ include "common.fullname" . }}-aaf-props-pvc
           emptyDir: {}
       {{- end }}
+      {{- end }}
+{{- if .Values.persistence.enabled }}
   volumeClaimTemplates:
   - metadata:
-      name: {{ include "common.fullname" . }}-spool-data-pvc
+      name: {{ include "common.fullname" . }}-data
       labels:
         name: {{ include "common.fullname" . }}
     spec:
-      accessModes: [ {{ .Values.persistence.accessMode }} ]
-      storageClassName: {{ include "common.fullname" . }}-spool-data-stcl
+      accessModes:
+      - {{ .Values.persistence.accessMode }}
+      storageClassName: {{ include "common.storageClass" . }}
       resources:
         requests:
           storage: {{ .Values.persistence.spoolSize }}
-      selector:
-        matchLabels:
-          name: {{ include "common.fullname" . }}-spool-data-pv
   - metadata:
-      name: {{ include "common.fullname" . }}-event-logs-pvc
+      name: {{ include "common.fullname" . }}-event-logs
       labels:
         name: {{ include "common.fullname" . }}
     spec:
-      accessModes: [ {{ .Values.persistence.accessMode }} ]
-      storageClassName: {{ include "common.fullname" . }}-event-logs-stcl
+      accessModes:
+      - {{ .Values.persistence.accessMode }}
+      {{- if eq "True" (include "common.needPV" .) }}
+      storageClassName: "{{ include "common.fullname" . }}-data-event-logs"
+      {{- else }}
+      storageClassName: {{ include "common.storageClass" . }}
+      {{- end }}
       resources:
         requests:
           storage: {{ .Values.persistence.eventLogSize }}
-      selector:
-        matchLabels:
-          name: {{ include "common.fullname" . }}-event-logs-pv
 {{- if .Values.global.aafEnabled }}
   - metadata:
-      name: {{ include "common.fullname" . }}-aaf-props-pvc
+      name: {{ include "common.fullname" . }}-aaf-props
       labels:
         name: {{ include "common.fullname" . }}
     spec:
-      accessModes: [ {{ .Values.persistence.accessMode }} ]
-      storageClassName: {{ include "common.fullname" . }}-aaf-props-stcl
+      accessModes:
+      - {{ .Values.persistence.accessMode }}
+      {{- if eq "True" (include "common.needPV" .) }}
+      storageClassName: "{{ include "common.fullname" . }}-data-aaf-props"
+      {{- else }}
+      storageClassName: {{ include "common.storageClass" . }}
+      {{- end }}
       resources:
         requests:
           storage: {{ .Values.persistence.aafCredsSize }}
-      selector:
-        matchLabels:
-          name: {{ include "common.fullname" . }}-aaf-props-pv
+{{- end }}
 {{- end }}
diff --git a/kubernetes/dmaap/components/dmaap-dr-prov/templates/deployment.yaml b/kubernetes/dmaap/components/dmaap-dr-prov/templates/deployment.yaml
index a1d148d..52ac9eb 100644
--- a/kubernetes/dmaap/components/dmaap-dr-prov/templates/deployment.yaml
+++ b/kubernetes/dmaap/components/dmaap-dr-prov/templates/deployment.yaml
@@ -162,8 +162,12 @@
         emptyDir: {}
       {{- if .Values.global.aafEnabled }}
       - name: {{ include "common.fullname" . }}-aaf-config-vol
+        {{- if .Values.persistence.enabled }}
         persistentVolumeClaim:
           claimName: {{ include "common.fullname" . }}-aaf-props
-      {{ end }}
+        {{- else }}
+        emptyDir: {}
+        {{- end }}
+      {{- end }}
       imagePullSecrets:
       - name: "{{ include "common.namespace" . }}-docker-registry-key"
diff --git a/kubernetes/dmaap/components/dmaap-dr-prov/templates/pv.yaml b/kubernetes/dmaap/components/dmaap-dr-prov/templates/pv.yaml
index b82e676..fba1bf9 100644
--- a/kubernetes/dmaap/components/dmaap-dr-prov/templates/pv.yaml
+++ b/kubernetes/dmaap/components/dmaap-dr-prov/templates/pv.yaml
@@ -18,6 +18,8 @@
   # ============LICENSE_END=========================================================
 */}}
 {{- if .Values.global.aafEnabled }}
+{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
+{{- if eq "True" (include "common.needPV" .) -}}
 kind: PersistentVolume
 apiVersion: v1
 metadata:
@@ -34,8 +36,10 @@
     storage: {{ .Values.persistence.aafCredsSize}}
   accessModes:
     - {{ .Values.persistence.accessMode }}
-  storageClassName: "{{ include "common.fullname" . }}-aaf-props-stcl"
+  storageClassName: "{{ include "common.fullname" . }}-data"
   persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
   hostPath:
     path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.aafCredsMountSubPath }}
 {{ end -}}
+{{- end -}}
+{{- end -}}
diff --git a/kubernetes/dmaap/components/dmaap-dr-prov/templates/pvc.yaml b/kubernetes/dmaap/components/dmaap-dr-prov/templates/pvc.yaml
index 6ff9e6d..b75daf5 100644
--- a/kubernetes/dmaap/components/dmaap-dr-prov/templates/pvc.yaml
+++ b/kubernetes/dmaap/components/dmaap-dr-prov/templates/pvc.yaml
@@ -18,6 +18,7 @@
   # ============LICENSE_END=========================================================
 */}}
 {{- if .Values.global.aafEnabled }}
+{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
 kind: PersistentVolumeClaim
 apiVersion: v1
 metadata:
@@ -33,13 +34,11 @@
 {{ toYaml .Values.persistence.annotations | indent 4 }}
 {{- end }}
 spec:
-  selector:
-    matchLabels:
-      name: {{ include "common.fullname" . }}-aaf-props
   accessModes:
     - {{ .Values.persistence.accessMode }}
-  storageClassName: "{{ include "common.fullname" . }}-aaf-props-stcl"
+  storageClassName: {{ include "common.storageClass" . }}
   resources:
     requests:
       storage: {{ .Values.persistence.aafCredsSize }}
-{{ end -}}
\ No newline at end of file
+{{ end -}}
+{{ end -}}
diff --git a/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/pv.yaml b/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/pv.yaml
index 44c9576..3dca738 100644
--- a/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/pv.yaml
+++ b/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/pv.yaml
@@ -12,28 +12,30 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-{{- $root := . -}}
+{{- $global := . -}}
 {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
-{{ range $i, $e := until (atoi (quote $root.Values.replicaCount) | default 3) }}
+{{- if eq "True" (include "common.needPV" .) -}}
+{{ range $i, $e := until (atoi (quote $global.Values.replicaCount) | default 3) }}
 ---
 apiVersion: v1
 kind: PersistentVolume
 metadata:
-  name: {{ $root.Release.Name }}-{{ $root.Values.service.name }}-{{ $i }}
-  namespace: {{ $root.Release.Namespace }}
+  name: {{ $global.Release.Name }}-{{ $global.Values.service.name }}-{{ $i }}
+  namespace: {{ $global.Release.Namespace }}
   labels:
-    app: {{ $root.Values.service.name }}
-    chart: {{ $root.Chart.Name }}-{{ $root.Chart.Version | replace "+" "_" }}
-    release: {{ $root.Release.Name }}
-    heritage: {{ $root.Release.Service }}
+    app: {{ $global.Values.service.name }}
+    chart: {{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}
+    release: {{ $global.Release.Name }}
+    heritage: {{ $global.Release.Service }}
 spec:
   capacity:
-    storage: {{ $root.Values.persistence.size }}
+    storage: {{ $global.Values.persistence.size }}
   accessModes:
-    - {{ $root.Values.persistence.accessMode }}
+    - {{ $global.Values.persistence.accessMode }}
+  storageClassName: "{{ include "common.fullname" $global }}-data"
   hostPath:
-    path: {{ $root.Values.persistence.mountPath }}/{{ $root.Release.Name }}/{{ $root.Values.persistence.mountSubPath }}-{{ $i }}
-  persistentVolumeReclaimPolicy: {{ $root.Values.persistence.volumeReclaimPolicy }}
+    path: {{ $global.Values.persistence.mountPath }}/{{ $global.Release.Name }}/{{ $global.Values.persistence.mountSubPath }}-{{ $i }}
+  persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
 {{ end }}
 {{ end }}
-
+{{ end }}
diff --git a/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/statefulset.yaml b/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/statefulset.yaml
index 3be8d5d..104a46b 100644
--- a/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/statefulset.yaml
+++ b/kubernetes/dmaap/components/message-router/charts/message-router-kafka/templates/statefulset.yaml
@@ -187,15 +187,10 @@
       spec:
         accessModes:
           - {{ .Values.persistence.accessMode | quote }}
+        storageClassName: {{ include "common.storageClass" . }}
         resources:
           requests:
             storage: {{ .Values.persistence.size | quote }}
-        selector:
-          matchLabels:
-            release: "{{ .Release.Name }}"
-            app: {{ .Values.service.name }}
-            chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
-            heritage: "{{ .Release.Service }}"
 {{ end }}
       imagePullSecrets:
-      - name: "{{ include "common.namespace" . }}-docker-registry-key"
\ No newline at end of file
+      - name: "{{ include "common.namespace" . }}-docker-registry-key"
diff --git a/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/pv.yaml b/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/pv.yaml
index 44c9576..3dca738 100644
--- a/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/pv.yaml
+++ b/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/pv.yaml
@@ -12,28 +12,30 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-{{- $root := . -}}
+{{- $global := . -}}
 {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
-{{ range $i, $e := until (atoi (quote $root.Values.replicaCount) | default 3) }}
+{{- if eq "True" (include "common.needPV" .) -}}
+{{ range $i, $e := until (atoi (quote $global.Values.replicaCount) | default 3) }}
 ---
 apiVersion: v1
 kind: PersistentVolume
 metadata:
-  name: {{ $root.Release.Name }}-{{ $root.Values.service.name }}-{{ $i }}
-  namespace: {{ $root.Release.Namespace }}
+  name: {{ $global.Release.Name }}-{{ $global.Values.service.name }}-{{ $i }}
+  namespace: {{ $global.Release.Namespace }}
   labels:
-    app: {{ $root.Values.service.name }}
-    chart: {{ $root.Chart.Name }}-{{ $root.Chart.Version | replace "+" "_" }}
-    release: {{ $root.Release.Name }}
-    heritage: {{ $root.Release.Service }}
+    app: {{ $global.Values.service.name }}
+    chart: {{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}
+    release: {{ $global.Release.Name }}
+    heritage: {{ $global.Release.Service }}
 spec:
   capacity:
-    storage: {{ $root.Values.persistence.size }}
+    storage: {{ $global.Values.persistence.size }}
   accessModes:
-    - {{ $root.Values.persistence.accessMode }}
+    - {{ $global.Values.persistence.accessMode }}
+  storageClassName: "{{ include "common.fullname" $global }}-data"
   hostPath:
-    path: {{ $root.Values.persistence.mountPath }}/{{ $root.Release.Name }}/{{ $root.Values.persistence.mountSubPath }}-{{ $i }}
-  persistentVolumeReclaimPolicy: {{ $root.Values.persistence.volumeReclaimPolicy }}
+    path: {{ $global.Values.persistence.mountPath }}/{{ $global.Release.Name }}/{{ $global.Values.persistence.mountSubPath }}-{{ $i }}
+  persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
 {{ end }}
 {{ end }}
-
+{{ end }}
diff --git a/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/statefulset.yaml b/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/statefulset.yaml
index df17ca8..17b87f8 100644
--- a/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/statefulset.yaml
+++ b/kubernetes/dmaap/components/message-router/charts/message-router-zookeeper/templates/statefulset.yaml
@@ -133,17 +133,10 @@
       spec:
         accessModes:
           - {{ .Values.persistence.accessMode | quote }}
+        storageClassName: {{ include "common.storageClass" . }}
         resources:
           requests:
             storage: {{ .Values.persistence.size | quote }}
-        selector:
-          matchLabels:
-            release: "{{ .Release.Name }}"
-            app: {{ .Values.service.name }}
-            chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
-            heritage: "{{ .Release.Service }}"
 {{ end }}
       imagePullSecrets:
       - name: "{{ include "common.namespace" . }}-docker-registry-key"
-
-