Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / common / common / templates / _resources.tpl
1 {{- /*
2 # Copyright © 2018 Amdocs, Bell Canada
3 #
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
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 */ -}}
16
17 {{- /*
18   Resolve the name of the common resource limit/request flavor.
19   The value for .Values.flavor is used by default,
20   unless either override mechanism is used.
21
22   - .Values.global.flavor  : override default flavor for all charts
23   - .Values.flavorOverride : override global and default flavor on a per chart basis
24 */ -}}
25 {{- define "common.flavor" -}}
26   {{if .Values.flavorOverride }}
27     {{- printf "%s" .Values.flavorOverride -}}
28   {{else}}
29     {{- default .Values.flavor .Values.global.flavor -}}
30   {{end}}
31 {{- end -}}
32
33 {{- /*
34   Resolve the resource limit/request flavor using the desired flavor value.
35
36   - .Values.resources  : YAML definition of resource limits.  The flavor key
37                         is computed based on the common.flavor template and
38                         is used as the selected resource limit through the pluck
39   e.g:  resources:
40           small:
41             limits:
42               cpu: 200m
43               memory: 4Gi
44             requests:
45               cpu: 100m
46               memory: 1Gi
47           large:
48             limits:
49               cpu: 400m
50               memory: 8Gi
51             requests:
52               cpu: 200m
53               memory: 2Gi
54           unlimited: {}
55 */ -}}
56 {{- define "common.resources" -}}
57 {{- $flavor := include "common.flavor" . -}}
58 {{- toYaml (pluck $flavor .Values.resources | first) | indent 12 -}}
59 {{- end -}}