blob: 8b1fd095136f3e3e5a03ee4740a31e3bc3271feb [file] [log] [blame]
Giorgi Lekveishvili725bb392023-05-05 18:24:27 +04001{{/* 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{{/*
34Create a default fully qualified controller name.
35We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
36*/}}
37{{- define "ingress-nginx.controller.fullname" -}}
38{{- printf "%s-%s" (include "ingress-nginx.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}}
39{{- end -}}
40
41{{/*
42Construct the path for the publish-service.
43
44By convention this will simply use the <namespace>/<controller-name> to match the name of the
45service generated.
46
47Users can provide an override for an explicit service they want bound via `.Values.controller.publishService.pathOverride`
48
49*/}}
50{{- define "ingress-nginx.controller.publishServicePath" -}}
51{{- $defServiceName := printf "%s/%s" "$(POD_NAMESPACE)" (include "ingress-nginx.controller.fullname" .) -}}
52{{- $servicePath := default $defServiceName .Values.controller.publishService.pathOverride }}
53{{- print $servicePath | trimSuffix "-" -}}
54{{- end -}}
55
56{{/*
57Create a default fully qualified default backend name.
58We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
59*/}}
60{{- define "ingress-nginx.defaultBackend.fullname" -}}
61{{- printf "%s-%s" (include "ingress-nginx.fullname" .) .Values.defaultBackend.name | trunc 63 | trimSuffix "-" -}}
62{{- end -}}
63
64{{/*
65Common labels
66*/}}
67{{- define "ingress-nginx.labels" -}}
68helm.sh/chart: {{ include "ingress-nginx.chart" . }}
69{{ include "ingress-nginx.selectorLabels" . }}
70{{- if .Chart.AppVersion }}
71app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
72{{- end }}
73app.kubernetes.io/managed-by: {{ .Release.Service }}
74{{- end -}}
75
76{{/*
77Selector labels
78*/}}
79{{- define "ingress-nginx.selectorLabels" -}}
80app.kubernetes.io/name: {{ include "ingress-nginx.name" . }}
81app.kubernetes.io/instance: {{ .Release.Name }}
82{{- end -}}
83
84{{/*
85Create the name of the controller service account to use
86*/}}
87{{- define "ingress-nginx.serviceAccountName" -}}
88{{- if .Values.serviceAccount.create -}}
89 {{ default (include "ingress-nginx.fullname" .) .Values.serviceAccount.name }}
90{{- else -}}
91 {{ default "default" .Values.serviceAccount.name }}
92{{- end -}}
93{{- end -}}
94
95{{/*
96Create the name of the backend service account to use - only used when podsecuritypolicy is also enabled
97*/}}
98{{- define "ingress-nginx.defaultBackend.serviceAccountName" -}}
99{{- if .Values.defaultBackend.serviceAccount.create -}}
100 {{ default (printf "%s-backend" (include "ingress-nginx.fullname" .)) .Values.defaultBackend.serviceAccount.name }}
101{{- else -}}
102 {{ default "default-backend" .Values.defaultBackend.serviceAccount.name }}
103{{- end -}}
104{{- end -}}
105
106{{/*
107Return the appropriate apiGroup for PodSecurityPolicy.
108*/}}
109{{- define "podSecurityPolicy.apiGroup" -}}
110{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
111{{- print "policy" -}}
112{{- else -}}
113{{- print "extensions" -}}
114{{- end -}}
115{{- end -}}
116
117{{/*
118Check the ingress controller version tag is at most three versions behind the last release
119*/}}
120{{- define "isControllerTagValid" -}}
121{{- if not (semverCompare ">=0.27.0-0" .Values.controller.image.tag) -}}
122{{- fail "Controller container image tag should be 0.27.0 or higher" -}}
123{{- end -}}
124{{- end -}}
125
126{{/*
127IngressClass parameters.
128*/}}
129{{- define "ingressClass.parameters" -}}
130 {{- if .Values.controller.ingressClassResource.parameters -}}
131 parameters:
132{{ toYaml .Values.controller.ingressClassResource.parameters | indent 4}}
133 {{ end }}
134{{- end -}}