1
+ { {/* vim: set filetype= mustache: */} }
2
+
3
+ { {/*
4
+ Expand the name of the chart.
5
+ */} }
6
+ { {- define " nginx.name" -} }
7
+ { {- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix " -" } }
8
+ { {- end } }
9
+
10
+ { {/*
11
+ Create a default fully qualified nginx name.
12
+ We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
13
+ If release name contains chart name it will be used as a full name.
14
+ */} }
15
+ { {- define " nginx.fullname" -} }
16
+ { {- if .Values.fullnameOverride } }
17
+ { {- .Values.fullnameOverride | trunc 63 | trimSuffix " -" } }
18
+ { {- else } }
19
+ { {- $name := default .Chart.Name .Values.nameOverride } }
20
+ { {- if contains $name .Release.Name } }
21
+ { {- .Release.Name | trunc 63 | trimSuffix " -" } }
22
+ { {- else } }
23
+ { {- printf " %s-%s" .Release.Name $name | trunc 63 | trimSuffix " -" } }
24
+ { {- end } }
25
+ { {- end } }
26
+ { {- end } }
27
+
28
+ { {/*
29
+ Create chart name and version as used by the chart label.
30
+ */} }
31
+ { {- define " nginx.chart" -} }
32
+ { {- printf " %s-%s" .Chart.Name .Chart.Version | replace " +" " _" | trunc 63 | trimSuffix " -" } }
33
+ { {- end } }
34
+
35
+ { {/*
36
+ Common labels
37
+ */} }
38
+ { {- define " nginx.labels" -} }
39
+ helm.sh/chart: { { include " nginx.chart" . } }
40
+ { { include " nginx.selectorLabels" . } }
41
+ { {- if .Chart.AppVersion } }
42
+ app.kubernetes.io/version: { { .Chart.AppVersion | quote } }
43
+ { {- end } }
44
+ wandb.com/app-name: { { include " nginx.chart" . } }
45
+ app.kubernetes.io/managed-by: { { .Release.Service } }
46
+ { {- end } }
47
+
48
+ { {/*
49
+ Selector labels
50
+ */} }
51
+ { {- define " nginx.selectorLabels" -} }
52
+ app.kubernetes.io/name: { { include " nginx.name" . } }
53
+ app.kubernetes.io/instance: { { .Release.Name } }
54
+ { {- end } }
55
+
56
+ { {/*
57
+ Create the name of the service account to use
58
+ */} }
59
+ { {- define " nginx.serviceAccountName" -} }
60
+ { {- if .Values.serviceAccount.create } }
61
+ { {- default (include " nginx.fullname" .) .Values.serviceAccount.name } }
62
+ { {- else } }
63
+ { {- default " default" .Values.serviceAccount.name } }
64
+ { {- end } }
65
+ { {- end } }
66
+
67
+
68
+ { {/*
69
+ Returns a list of _common_ labels to be shared across all
70
+ app deployments and other shared objects.
71
+ */} }
72
+ { {- define " nginx.commonLabels" -} }
73
+ { {- $commonLabels := default (dict) .Values.common.labels -} }
74
+ { {- if $commonLabels } }
75
+ { {- range $key , $value := $commonLabels } }
76
+ { { $key } }: { { $value | quote } }
77
+ { {- end } }
78
+ { {- end -} }
79
+ { {- end -} }
80
+
81
+ { {/*
82
+ Returns a list of _pod_ labels to be shared across all
83
+ nginx deployments.
84
+ */} }
85
+ { {- define " nginx.podLabels" -} }
86
+ { {- range $key , $value := .Values.pod.labels } }
87
+ { { $key } }: { { $value | quote } }
88
+ { {- end } }
89
+ { {- end -} }
90
+
91
+
92
+ { {- define " nginx.nodeSelector" -} }
93
+ { {- $nodeSelector := default .Values.global.nodeSelector .Values.nodeSelector -} }
94
+ { {- if $nodeSelector } }
95
+ nodeSelector:
96
+ { {- toYaml $nodeSelector | nindent 2 } }
97
+ { {- end } }
98
+ { {- end -} }
99
+
100
+
101
+ { {/*
102
+ Return a PodSecurityContext definition.
103
+
104
+ Usage:
105
+ {{ include " nginx.podSecurityContext" .Values.pod.securityContext } }
106
+ */}}
107
+ { {- define " nginx.podSecurityContext" -} }
108
+ { {- $psc := . } }
109
+ { {- if $psc } }
110
+ securityContext:
111
+ { {- if not (empty $psc .runAsUser) } }
112
+ runAsUser: { { $psc .runAsUser } }
113
+ { {- end } }
114
+ { {- if not (empty $psc .runAsGroup) } }
115
+ runAsGroup: { { $psc .runAsGroup } }
116
+ { {- end } }
117
+ { {- if not (empty $psc .fsGroup) } }
118
+ fsGroup: { { $psc .fsGroup } }
119
+ { {- end } }
120
+ { {- if not (empty $psc .fsGroupChangePolicy) } }
121
+ fsGroupChangePolicy: { { $psc .fsGroupChangePolicy } }
122
+ { {- end } }
123
+ { {- end } }
124
+ { {- end -} }
0 commit comments