Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / mongodb / common / templates / _warnings.tpl
1 {{/*
2 Copyright VMware, Inc.
3 SPDX-License-Identifier: APACHE-2.0
4 */}}
5
6 {{/* vim: set filetype=mustache: */}}
7 {{/*
8 Warning about using rolling tag.
9 Usage:
10 {{ include "common.warnings.rollingTag" .Values.path.to.the.imageRoot }}
11 */}}
12 {{- define "common.warnings.rollingTag" -}}
13
14 {{- if and (contains "bitnami/" .repository) (not (.tag | toString | regexFind "-r\\d+$|sha256:")) }}
15 WARNING: Rolling tag detected ({{ .repository }}:{{ .tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
16 +info https://docs.bitnami.com/tutorials/understand-rolling-tags-containers
17 {{- end }}
18 {{- end -}}
19
20 {{/*
21 Warning about not setting the resource object in all deployments.
22 Usage:
23 {{ include "common.warnings.resources" (dict "sections" (list "path1" "path2") context $) }}
24 Example:
25 {{- include "common.warnings.resources" (dict "sections" (list "csiProvider.provider" "server" "volumePermissions" "") "context" $) }}
26 The list in the example assumes that the following values exist:
27   - csiProvider.provider.resources
28   - server.resources
29   - volumePermissions.resources
30   - resources
31 */}}
32 {{- define "common.warnings.resources" -}}
33 {{- $values := .context.Values -}}
34 {{- $printMessage := false -}}
35 {{ $affectedSections := list -}}
36 {{- range .sections -}}
37   {{- if eq . "" -}}
38     {{/* Case where the resources section is at the root (one main deployment in the chart) */}}
39     {{- if not (index $values "resources") -}}
40     {{- $affectedSections = append $affectedSections "resources" -}}
41     {{- $printMessage = true -}}
42     {{- end -}}
43   {{- else -}}
44     {{/* Case where the are multiple resources sections (more than one main deployment in the chart) */}}
45     {{- $keys := split "." . -}}
46     {{/* We iterate through the different levels until arriving to the resource section. Example: a.b.c.resources */}}
47     {{- $section := $values -}}
48     {{- range $keys -}}
49       {{- $section = index $section . -}}
50     {{- end -}}
51     {{- if not (index $section "resources") -}}
52       {{/* If the section has enabled=false or replicaCount=0, do not include it */}}
53       {{- if and (hasKey $section "enabled") -}}
54         {{- if index $section "enabled" -}}
55           {{/* enabled=true */}}
56           {{- $affectedSections = append $affectedSections (printf "%s.resources" .) -}}
57           {{- $printMessage = true -}}
58         {{- end -}}
59       {{- else if and (hasKey $section "replicaCount")  -}}
60         {{/* We need a casting to int because number 0 is not treated as an int by default */}}
61         {{- if (gt (index $section "replicaCount" | int) 0) -}}
62           {{/* replicaCount > 0 */}}
63           {{- $affectedSections = append $affectedSections (printf "%s.resources" .) -}}
64           {{- $printMessage = true -}}
65         {{- end -}}
66       {{- else -}}
67         {{/* Default case, add it to the affected sections */}}
68         {{- $affectedSections = append $affectedSections (printf "%s.resources" .) -}}
69         {{- $printMessage = true -}}
70       {{- end -}}
71     {{- end -}}
72   {{- end -}}
73 {{- end -}}
74 {{- if $printMessage }}
75
76 WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
77 {{- range $affectedSections }}
78   - {{ . }}
79 {{- end }}
80 +info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
81 {{- end -}}
82 {{- end -}}