2 # Copyright © 2019 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.
21 The function takes several arguments (inside a dictionary):
22 - .dot : environment (.)
23 - .labels : labels to add (dict)
25 {{- define "common.labels" -}}
26 {{- $dot := default . .dot -}}
27 app.kubernetes.io/name: {{ include "common.name" $dot }}
28 helm.sh/chart: {{ include "common.chart" $dot }}
29 app.kubernetes.io/instance: {{ include "common.release" $dot }}
30 app.kubernetes.io/managed-by: {{ $dot.Release.Service }}
32 {{- include "common.tplValue" (dict "value" .labels "context" $dot) }}
37 Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
38 The function takes several arguments (inside a dictionary):
39 - .dot : environment (.)
40 - .matchLabels: selectors/matchlLabels to add (dict)
42 {{- define "common.matchLabels" -}}
43 {{- $dot := default . .dot -}}
44 {{- if not .matchLabels.nameNoMatch -}}
45 app.kubernetes.io/name: {{ include "common.name" $dot }}
47 app.kubernetes.io/instance: {{ include "common.release" $dot }}
49 {{$_ := unset .matchLabels "nameNoMatch"}}
50 {{- include "common.tplValue" (dict "value" .matchLabels "context" $dot) }}
55 Generate "top" metadata for Deployment / StatefulSet / ...
56 The function takes several arguments (inside a dictionary):
57 - .dot : environment (.)
58 - .labels: labels to add (dict)
59 - .suffix: suffix to name
62 {{- define "common.resourceMetadata" -}}
63 {{- $dot := default . .dot -}}
64 {{- $suffix := default "" .suffix -}}
65 {{- $labels := default (dict) .labels -}}
66 {{- $annotations := default (dict) .annotations -}}
67 name: {{ include "common.fullname" (dict "suffix" $suffix "dot" $dot )}}
68 namespace: {{ include "common.namespace" $dot }}
69 labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot ) | nindent 2 }}
70 {{- if $annotations }}
71 annotations: {{- include "common.tplValue" (dict "value" $annotations "context" $dot) | nindent 2}}
76 Generate selectors for Deployment / StatefulSet / ...
77 The function takes several arguments (inside a dictionary):
78 - .dot : environment (.)
79 - .matchLabels: labels to add (dict)
81 {{- define "common.selectors" -}}
82 {{- $dot := default . .dot -}}
83 {{- $matchLabels := default (dict) .matchLabels -}}
84 matchLabels: {{- include "common.matchLabels" (dict "matchLabels" $matchLabels "dot" $dot) | nindent 2 }}
88 Generate "template" metadata for Deployment / StatefulSet / ...
89 The function takes several arguments (inside a dictionary)
90 - .dot : environment (.)
91 - .labels: labels to add (dict)
93 {{- define "common.templateMetadata" -}}
94 {{- $dot := default . .dot -}}
95 {{- $labels := default (dict) .labels -}}
96 {{- if $dot.Values.podAnnotations }}
97 annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $) | nindent 2 }}
99 labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot) | nindent 2 }}
100 name: {{ include "common.name" $dot }}