2 # Copyright © 2019 Amdocs, Bell Canada, Orange
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 Expand the name of the storage class.
19 The value "common.fullname"-data is used by default,
20 unless either override mechanism is used.
22 - .Values.global.persistence.storageClass : override default storageClass for all charts
23 - .Values.persistence.storageClassOverride : override global and default storage class on a per chart basis
24 - .Values.persistence.storageClass : override default storage class on a per chart basis
26 {{- define "common.storageClass" -}}
27 {{- if .Values.persistence.storageClassOverride -}}
28 {{- if ne "-" .Values.persistence.storageClassOverride -}}
29 {{- printf "%s" .Values.persistence.storageClassOverride -}}
31 {{- $storage_class := "" -}}
32 {{- printf "%q" $storage_class -}}
35 {{- if or .Values.persistence.storageClass .Values.global.persistence.storageClass }}
36 {{- if ne "-" (default .Values.persistence.storageClass .Values.global.persistence.storageClass) -}}
37 {{- printf "%s" (default .Values.persistence.storageClass .Values.global.persistence.storageClass) -}}
39 {{- $storage_class := "" -}}
40 {{- printf "%q" $storage_class -}}
43 {{- printf "%s-data" (include "common.fullname" .) -}}
49 Calculate if we need a PV. If a storageClass is provided, then we don't need.
51 {{- define "common.needPV" -}}
52 {{- if not (or (or .Values.persistence.storageClassOverride .Values.persistence.storageClass) .Values.global.persistence.storageClass) -}}
58 Generate N PV for a statefulset
60 {{- define "common.replicaPV" -}}
62 {{- if and $global.Values.persistence.enabled (not $global.Values.persistence.existingClaim) }}
63 {{- if (include "common.needPV" .) -}}
64 {{- range $i := until (int $global.Values.replicaCount)}}
66 kind: PersistentVolume
69 name: {{ include "common.fullname" $global }}-data-{{$i}}
70 namespace: {{ include "common.namespace" $global }}
71 labels: {{- include "common.labels" $global | nindent 4 }}
74 storage: {{ $global.Values.persistence.size}}
76 - {{ $global.Values.persistence.accessMode }}
77 persistentVolumeReclaimPolicy: {{ $global.Values.persistence.volumeReclaimPolicy }}
78 storageClassName: "{{ include "common.fullname" $global }}-data"
80 path: {{ $global.Values.global.persistence.mountPath | default $global.Values.persistence.mountPath }}/{{ include "common.release" $global }}/{{ $global.Values.persistence.mountSubPath }}-{{$i}}