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 Give the root folder for ONAP when using host pathes
20 The function takes up to two arguments (inside a dictionary):
21 - .dot : environment (.)
22 - .subPath: the sub path to use, default to
23 ".Values.persistence.mountSubPath"
26 {{ include "common.storageClass" . }}
27 {{ include "common.storageClass" (dict "dot" . "subPath" "my-awesome-subPath") }}
29 {{- define "common.persistencePath" -}}
30 {{- $dot := default . .dot -}}
31 {{- $subPath := default $dot.Values.persistence.mountSubPath .subPath -}}
32 {{ $dot.Values.global.persistence.mountPath | default $dot.Values.persistence.mountPath }}/{{ include "common.release" $dot }}/{{ $subPath }}
36 Expand the name of the storage class.
37 The value "common.fullname"-data is used by default,
38 unless either override mechanism is used.
40 - .Values.global.persistence.storageClass : override default storageClass for
42 - .Values.persistence.storageClassOverride : override global and default
43 storage class on a per chart
45 - .Values.persistence.storageClass : override default storage class on
48 The function takes up to two arguments (inside a dictionary):
49 - .dot : environment (.)
50 - .suffix: suffix to name. if not set, default to "data" when no override
52 - .persistenceInfos: the persitence values to use, default to
53 `.Values.persistence`.
54 Need to be the dict key from `.Values` in string
62 accessMode: ReadWriteOnce
65 then you have to put `.Values.persitence.logs` in
70 {{ include "common.storageClass" . }}
71 {{ include "common.storageClass" (dict "dot" . "suffix" "my-awesome-suffix") }}
72 {{ include "common.storageClass" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
74 {{- define "common.storageClass" -}}
75 {{- $dot := default . .dot -}}
76 {{- $suffix := default "data" .suffix -}}
77 {{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
78 {{- if $persistenceInfos.storageClassOverride -}}
79 {{- if ne "-" $persistenceInfos.storageClassOverride -}}
80 {{- $persistenceInfos.storageClassOverride -}}
82 {{- $storage_class := "" -}}
83 {{- printf "%q" $storage_class -}}
86 {{- if or $persistenceInfos.storageClass $dot.Values.global.persistence.storageClass }}
87 {{- if ne "-" (default $persistenceInfos.storageClass $dot.Values.global.persistence.storageClass) -}}
88 {{- default $persistenceInfos.storageClass $dot.Values.global.persistence.storageClass -}}
90 {{- $storage_class := "" -}}
91 {{- printf "%q" $storage_class -}}
94 {{- printf "%s-%s" (include "common.fullname" $dot) $suffix -}}
100 Calculate if we need a PV. If a storageClass is provided, then we don't need.
102 {{- define "common.needPV" -}}
103 {{- if not (or (or .Values.persistence.storageClassOverride .Values.persistence.storageClass) .Values.global.persistence.storageClass) -}}
111 The function takes up to three arguments (inside a dictionary):
112 - .dot : environment (.)
113 - .suffix: suffix to name. if not set, default to "data".
114 - .persistenceInfos: the persitence values to use, default to
115 `.Values.persistence`.
116 Need to be the dict key from `.Values` in string
124 accessMode: ReadWriteOnce
127 then you have to put `.Values.persitence.logs` in
131 {{ include "common.PV" . }}
132 {{ include "common.PV" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos".Values.persistenceLog ) }}
133 {{ include "common.PV" (dict "dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
135 {{- define "common.PV" -}}
136 {{- $dot := default . .dot -}}
137 {{- $suffix := default "data" .suffix -}}
138 {{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
139 {{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
140 {{- if and $persistenceInfos.enabled (not $persistenceInfos.existingClaim) -}}
141 {{- if (include "common.needPV" $dot) -}}
142 kind: PersistentVolume
144 metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "suffix" $suffix "labels" $persistenceInfos.labels) | nindent 2 }}
147 storage: {{ $persistenceInfos.size }}
149 - {{ $persistenceInfos.accessMode }}
150 persistentVolumeReclaimPolicy: {{ $persistenceInfos.volumeReclaimPolicy }}
151 storageClassName: "{{ include "common.fullname" $dot }}-{{ $suffix }}"
153 path: {{ include "common.persistencePath" (dict "dot" $dot "subPath" $persistenceInfos.mountSubPath) }}
159 Generate N PV for a statefulset
161 The function takes up to two arguments (inside a dictionary):
162 - .dot : environment (.)
163 - .suffix: suffix to name. if not set, default to "data".
164 - .persistenceInfos: the persitence values to use, default to
165 `.Values.persistence`.
166 Need to be the dict key from `.Values` in string
174 accessMode: ReadWriteOnce
177 then you have to put `.Values.persitence.logs` in
181 {{ include "common.replicaPV" . }}
182 {{ include "common.replicaPV" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
183 {{ include "common.replicaPV" (dict dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
185 {{- define "common.replicaPV" -}}
186 {{- $dot := default . .dot -}}
187 {{- $suffix := default "data" .suffix -}}
188 {{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
189 {{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
190 {{- if and $persistenceInfos.enabled (not $persistenceInfos.existingClaim) -}}
191 {{- if (include "common.needPV" $dot) -}}
192 {{/* TODO: see if we can use "common.PV" after branching F release */}}
193 {{- range $i := until (int $dot.Values.replicaCount) }}
194 {{- $range_suffix := printf "%s-%d" $metadata_suffix $i }}
196 kind: PersistentVolume
198 metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "suffix" $range_suffix "labels" $persistenceInfos.labels) | nindent 2 }}
201 storage: {{ $persistenceInfos.size }}
203 - {{ $persistenceInfos.accessMode }}
204 persistentVolumeReclaimPolicy: {{ $persistenceInfos.volumeReclaimPolicy }}
205 storageClassName: "{{ include "common.fullname" $dot }}-{{ $suffix }}"
207 path: {{ include "common.persistencePath" (dict "dot" $dot "subPath" $persistenceInfos.mountSubPath) }}-{{ $i }}
216 The function takes up to two arguments (inside a dictionary):
217 - .dot : environment (.)
218 - .suffix: suffix to name. if not set, default to "data".
219 - .persistenceInfos: the persitence values to use, default to
220 `.Values.persistence`.
221 Need to be the dict key from `.Values` in string
229 accessMode: ReadWriteOnce
232 then you have to put `.Values.persitence.logs` in
236 {{ include "common.PVC" . }}
237 {{ include "common.PVC" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
238 {{ include "common.PVC" (dict dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
240 {{- define "common.PVC" -}}
241 {{- $dot := default . .dot -}}
242 {{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
243 {{- $suffix := default "data" .suffix -}}
244 {{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
245 {{- if and $persistenceInfos.enabled (not $persistenceInfos.existingClaim) -}}
246 kind: PersistentVolumeClaim
248 {{ include "common.PVCTemplate" (dict "dot" $dot "suffix" $suffix "persistenceInfos" $persistenceInfos) }}
253 Generate a PVC template for a statefulset
255 The function takes up to two arguments (inside a dictionary):
256 - .dot : environment (.)
257 - .suffix: suffix to name. if not set, default to "data".
258 - .persistenceInfos: the persitence values to use, default to
259 `.Values.persistence`.
260 Need to be the dict key from `.Values` in string
268 accessMode: ReadWriteOnce
271 then you have to put `.Values.persitence.logs` in
275 {{ include "common.PVCTemplate" . }}
276 {{ include "common.PVCTemplate" (dict "dot" . "suffix" "my-awesome-suffix" "persistenceInfos" .Values.persistenceLog) }}
277 {{ include "common.PVCTemplate" (dict dot" . "subPath" "persistenceInfos" .Values.persistence.log) }}
279 {{- define "common.PVCTemplate" -}}
280 {{- $dot := default . .dot -}}
281 {{- $persistenceInfos := default $dot.Values.persistence .persistenceInfos -}}
282 {{- $suffix := default "data" .suffix -}}
283 {{- $metadata_suffix := ternary "" $suffix (eq $suffix "data") -}}
284 metadata: {{- include "common.resourceMetadata" (dict "dot" $dot "suffix" $metadata_suffix "annotations" $persistenceInfos.annotations) | nindent 2 }}
287 - {{ $persistenceInfos.accessMode }}
288 storageClassName: {{ include "common.storageClass" (dict "dot" $dot "suffix" $suffix "persistenceInfos" $persistenceInfos ) }}
291 storage: {{ $persistenceInfos.size }}