blob: a72af5d9de14d2f7ec4372ff817830a7e90f8e99 [file] [log] [blame]
Mohammed Naser9ad0d462023-01-15 20:36:37 -05001{{/* vim: set filetype=mustache: */}}
2{{/*
3Expand the name of the chart.
4*/}}
5{{- define "ingress-nginx.name" -}}
6{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7{{- end -}}
8
9{{/*
10Create chart name and version as used by the chart label.
11*/}}
12{{- define "ingress-nginx.chart" -}}
13{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
14{{- end -}}
15
16{{/*
17Create a default fully qualified app name.
18We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
19*/}}
20{{- define "ingress-nginx.fullname" -}}
21{{- if .Values.fullnameOverride -}}
22{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
23{{- else -}}
24{{- $name := default .Chart.Name .Values.nameOverride -}}
25{{- if contains $name .Release.Name -}}
26{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
27{{- else -}}
28{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
29{{- end -}}
30{{- end -}}
31{{- end -}}
32
33
34{{/*
35Container SecurityContext.
36*/}}
37{{- define "controller.containerSecurityContext" -}}
38{{- if .Values.controller.containerSecurityContext -}}
39{{- toYaml .Values.controller.containerSecurityContext -}}
40{{- else -}}
41capabilities:
42 drop:
43 - ALL
44 add:
45 - NET_BIND_SERVICE
46runAsUser: {{ .Values.controller.image.runAsUser }}
47allowPrivilegeEscalation: {{ .Values.controller.image.allowPrivilegeEscalation }}
48{{- end }}
49{{- end -}}
50
51{{/*
52Create a default fully qualified controller name.
53We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
54*/}}
55{{- define "ingress-nginx.controller.fullname" -}}
56{{- printf "%s-%s" (include "ingress-nginx.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}}
57{{- end -}}
58
59{{/*
60Construct the path for the publish-service.
61
62By convention this will simply use the <namespace>/<controller-name> to match the name of the
63service generated.
64
65Users can provide an override for an explicit service they want bound via `.Values.controller.publishService.pathOverride`
66
67*/}}
68{{- define "ingress-nginx.controller.publishServicePath" -}}
69{{- $defServiceName := printf "%s/%s" "$(POD_NAMESPACE)" (include "ingress-nginx.controller.fullname" .) -}}
70{{- $servicePath := default $defServiceName .Values.controller.publishService.pathOverride }}
71{{- print $servicePath | trimSuffix "-" -}}
72{{- end -}}
73
74{{/*
75Create a default fully qualified default backend name.
76We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
77*/}}
78{{- define "ingress-nginx.defaultBackend.fullname" -}}
79{{- printf "%s-%s" (include "ingress-nginx.fullname" .) .Values.defaultBackend.name | trunc 63 | trimSuffix "-" -}}
80{{- end -}}
81
82{{/*
83Common labels
84*/}}
85{{- define "ingress-nginx.labels" -}}
86helm.sh/chart: {{ include "ingress-nginx.chart" . }}
87{{ include "ingress-nginx.selectorLabels" . }}
88{{- if .Chart.AppVersion }}
89app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
90{{- end }}
91app.kubernetes.io/part-of: {{ template "ingress-nginx.name" . }}
92app.kubernetes.io/managed-by: {{ .Release.Service }}
93{{- if .Values.commonLabels}}
94{{ toYaml .Values.commonLabels }}
95{{- end }}
96{{- end -}}
97
98{{/*
99Selector labels
100*/}}
101{{- define "ingress-nginx.selectorLabels" -}}
102app.kubernetes.io/name: {{ include "ingress-nginx.name" . }}
103app.kubernetes.io/instance: {{ .Release.Name }}
104{{- end -}}
105
106{{/*
107Create the name of the controller service account to use
108*/}}
109{{- define "ingress-nginx.serviceAccountName" -}}
110{{- if .Values.serviceAccount.create -}}
111 {{ default (include "ingress-nginx.fullname" .) .Values.serviceAccount.name }}
112{{- else -}}
113 {{ default "default" .Values.serviceAccount.name }}
114{{- end -}}
115{{- end -}}
116
117{{/*
118Create the name of the backend service account to use - only used when podsecuritypolicy is also enabled
119*/}}
120{{- define "ingress-nginx.defaultBackend.serviceAccountName" -}}
121{{- if .Values.defaultBackend.serviceAccount.create -}}
122 {{ default (printf "%s-backend" (include "ingress-nginx.fullname" .)) .Values.defaultBackend.serviceAccount.name }}
123{{- else -}}
124 {{ default "default-backend" .Values.defaultBackend.serviceAccount.name }}
125{{- end -}}
126{{- end -}}
127
128{{/*
129Return the appropriate apiGroup for PodSecurityPolicy.
130*/}}
131{{- define "podSecurityPolicy.apiGroup" -}}
132{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
133{{- print "policy" -}}
134{{- else -}}
135{{- print "extensions" -}}
136{{- end -}}
137{{- end -}}
138
139{{/*
140Check the ingress controller version tag is at most three versions behind the last release
141*/}}
142{{- define "isControllerTagValid" -}}
143{{- if not (semverCompare ">=0.27.0-0" .Values.controller.image.tag) -}}
144{{- fail "Controller container image tag should be 0.27.0 or higher" -}}
145{{- end -}}
146{{- end -}}
147
148{{/*
149IngressClass parameters.
150*/}}
151{{- define "ingressClass.parameters" -}}
152 {{- if .Values.controller.ingressClassResource.parameters -}}
153 parameters:
154{{ toYaml .Values.controller.ingressClassResource.parameters | indent 4}}
155 {{ end }}
156{{- end -}}