blob: 24714a523335a0fdf858c4fe3ddb424699224c20 [file] [log] [blame]
Giorgi Lekveishvili725bb392023-05-05 18:24:27 +04001{{- if or (eq .Values.controller.kind "Deployment") (eq .Values.controller.kind "Both") -}}
2{{- include "isControllerTagValid" . -}}
3apiVersion: apps/v1
4kind: Deployment
5metadata:
6 labels:
7 {{- include "ingress-nginx.labels" . | nindent 4 }}
8 app.kubernetes.io/component: controller
9 {{- with .Values.controller.labels }}
10 {{- toYaml . | nindent 4 }}
11 {{- end }}
12 name: {{ include "ingress-nginx.controller.fullname" . }}
13 namespace: {{ .Release.Namespace }}
14 {{- if .Values.controller.annotations }}
15 annotations: {{ toYaml .Values.controller.annotations | nindent 4 }}
16 {{- end }}
17spec:
18 selector:
19 matchLabels:
20 {{- include "ingress-nginx.selectorLabels" . | nindent 6 }}
21 app.kubernetes.io/component: controller
22 {{- if not .Values.controller.autoscaling.enabled }}
23 replicas: {{ .Values.controller.replicaCount }}
24 {{- end }}
25 revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
26 {{- if .Values.controller.updateStrategy }}
27 strategy:
28 {{ toYaml .Values.controller.updateStrategy | nindent 4 }}
29 {{- end }}
30 minReadySeconds: {{ .Values.controller.minReadySeconds }}
31 template:
32 metadata:
33 {{- if .Values.controller.podAnnotations }}
34 annotations:
35 {{- range $key, $value := .Values.controller.podAnnotations }}
36 {{ $key }}: {{ $value | quote }}
37 {{- end }}
38 {{- end }}
39 labels:
40 {{- include "ingress-nginx.selectorLabels" . | nindent 8 }}
41 app.kubernetes.io/component: controller
42 {{- if .Values.controller.podLabels }}
43 {{- toYaml .Values.controller.podLabels | nindent 8 }}
44 {{- end }}
45 spec:
46 {{- if .Values.controller.dnsConfig }}
47 dnsConfig: {{ toYaml .Values.controller.dnsConfig | nindent 8 }}
48 {{- end }}
49 {{- if .Values.controller.hostname }}
50 hostname: {{ toYaml .Values.controller.hostname | nindent 8 }}
51 {{- end }}
52 dnsPolicy: {{ .Values.controller.dnsPolicy }}
53 {{- if .Values.imagePullSecrets }}
54 imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
55 {{- end }}
56 {{- if .Values.controller.priorityClassName }}
57 priorityClassName: {{ .Values.controller.priorityClassName }}
58 {{- end }}
59 {{- if or .Values.controller.podSecurityContext .Values.controller.sysctls }}
60 securityContext:
61 {{- end }}
62 {{- if .Values.controller.podSecurityContext }}
63 {{- toYaml .Values.controller.podSecurityContext | nindent 8 }}
64 {{- end }}
65 {{- if .Values.controller.sysctls }}
66 sysctls:
67 {{- range $sysctl, $value := .Values.controller.sysctls }}
68 - name: {{ $sysctl | quote }}
69 value: {{ $value | quote }}
70 {{- end }}
71 {{- end }}
72 containers:
73 - name: {{ .Values.controller.containerName }}
74 {{- with .Values.controller.image }}
75 image: "{{- if .repository -}}{{ .repository }}{{ else }}{{ .registry }}/{{ .image }}{{- end -}}:{{ .tag }}{{- if (.digest) -}} @{{.digest}} {{- end -}}"
76 {{- end }}
77 imagePullPolicy: {{ .Values.controller.image.pullPolicy }}
78 {{- if .Values.controller.lifecycle }}
79 lifecycle: {{ toYaml .Values.controller.lifecycle | nindent 12 }}
80 {{- end }}
81 args:
82 - /nginx-ingress-controller
83 {{- if .Values.defaultBackend.enabled }}
84 - --default-backend-service=$(POD_NAMESPACE)/{{ include "ingress-nginx.defaultBackend.fullname" . }}
85 {{- end }}
86 {{- if .Values.controller.publishService.enabled }}
87 - --publish-service={{ template "ingress-nginx.controller.publishServicePath" . }}
88 {{- end }}
89 - --election-id={{ .Values.controller.electionID }}
90 - --controller-class={{ .Values.controller.ingressClassResource.controllerValue }}
91 - --configmap={{ default "$(POD_NAMESPACE)" .Values.controller.configMapNamespace }}/{{ include "ingress-nginx.controller.fullname" . }}
92 {{- if .Values.tcp }}
93 - --tcp-services-configmap={{ default "$(POD_NAMESPACE)" .Values.controller.tcp.configMapNamespace }}/{{ include "ingress-nginx.fullname" . }}-tcp
94 {{- end }}
95 {{- if .Values.udp }}
96 - --udp-services-configmap={{ default "$(POD_NAMESPACE)" .Values.controller.udp.configMapNamespace }}/{{ include "ingress-nginx.fullname" . }}-udp
97 {{- end }}
98 {{- if .Values.controller.scope.enabled }}
99 - --watch-namespace={{ default "$(POD_NAMESPACE)" .Values.controller.scope.namespace }}
100 {{- end }}
101 {{- if and .Values.controller.reportNodeInternalIp .Values.controller.hostNetwork }}
102 - --report-node-internal-ip-address={{ .Values.controller.reportNodeInternalIp }}
103 {{- end }}
104 {{- if .Values.controller.admissionWebhooks.enabled }}
105 - --validating-webhook=:{{ .Values.controller.admissionWebhooks.port }}
106 - --validating-webhook-certificate={{ .Values.controller.admissionWebhooks.certificate }}
107 - --validating-webhook-key={{ .Values.controller.admissionWebhooks.key }}
108 {{- end }}
109 {{- if .Values.controller.maxmindLicenseKey }}
110 - --maxmind-license-key={{ .Values.controller.maxmindLicenseKey }}
111 {{- end }}
112 {{- if .Values.controller.healthCheckHost }}
113 - --healthz-host={{ .Values.controller.healthCheckHost }}
114 {{- end }}
115 {{- if not (eq .Values.controller.healthCheckPath "/healthz") }}
116 - --health-check-path={{ .Values.controller.healthCheckPath }}
117 {{- end }}
118 {{- if .Values.controller.ingressClassByName }}
119 - --ingress-class-by-name=true
120 {{- end }}
121 {{- if .Values.controller.watchIngressWithoutClass }}
122 - --watch-ingress-without-class=true
123 {{- end }}
124 {{- range $key, $value := .Values.controller.extraArgs }}
125 {{- /* Accept keys without values or with false as value */}}
126 {{- if eq ($value | quote | len) 2 }}
127 - --{{ $key }}
128 {{- else }}
129 - --{{ $key }}={{ $value }}
130 {{- end }}
131 {{- end }}
132 securityContext:
133 capabilities:
134 drop:
135 - ALL
136 add:
137 - NET_BIND_SERVICE
138 runAsUser: {{ .Values.controller.image.runAsUser }}
139 allowPrivilegeEscalation: {{ .Values.controller.image.allowPrivilegeEscalation }}
140 env:
141 - name: POD_NAME
142 valueFrom:
143 fieldRef:
144 fieldPath: metadata.name
145 - name: POD_NAMESPACE
146 valueFrom:
147 fieldRef:
148 fieldPath: metadata.namespace
149 {{- if .Values.controller.enableMimalloc }}
150 - name: LD_PRELOAD
151 value: /usr/local/lib/libmimalloc.so
152 {{- end }}
153 {{- if .Values.controller.extraEnvs }}
154 {{- toYaml .Values.controller.extraEnvs | nindent 12 }}
155 {{- end }}
156 {{- if .Values.controller.startupProbe }}
157 startupProbe: {{ toYaml .Values.controller.startupProbe | nindent 12 }}
158 {{- end }}
159 livenessProbe: {{ toYaml .Values.controller.livenessProbe | nindent 12 }}
160 readinessProbe: {{ toYaml .Values.controller.readinessProbe | nindent 12 }}
161 ports:
162 {{- range $key, $value := .Values.controller.containerPort }}
163 - name: {{ $key }}
164 containerPort: {{ $value }}
165 protocol: TCP
166 {{- if $.Values.controller.hostPort.enabled }}
167 hostPort: {{ index $.Values.controller.hostPort.ports $key | default $value }}
168 {{- end }}
169 {{- end }}
170 {{- if .Values.controller.metrics.enabled }}
171 - name: metrics
172 containerPort: {{ .Values.controller.metrics.port }}
173 protocol: TCP
174 {{- end }}
175 {{- if .Values.controller.admissionWebhooks.enabled }}
176 - name: webhook
177 containerPort: {{ .Values.controller.admissionWebhooks.port }}
178 protocol: TCP
179 {{- end }}
180 {{- range $key, $value := .Values.tcp }}
181 - name: {{ $key }}-tcp
182 containerPort: {{ $key }}
183 protocol: TCP
184 {{- if $.Values.controller.hostPort.enabled }}
185 hostPort: {{ $key }}
186 {{- end }}
187 {{- end }}
188 {{- range $key, $value := .Values.udp }}
189 - name: {{ $key }}-udp
190 containerPort: {{ $key }}
191 protocol: UDP
192 {{- if $.Values.controller.hostPort.enabled }}
193 hostPort: {{ $key }}
194 {{- end }}
195 {{- end }}
196 {{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled) }}
197 volumeMounts:
198 {{- if .Values.controller.customTemplate.configMapName }}
199 - mountPath: /etc/nginx/template
200 name: nginx-template-volume
201 readOnly: true
202 {{- end }}
203 {{- if .Values.controller.admissionWebhooks.enabled }}
204 - name: webhook-cert
205 mountPath: /usr/local/certificates/
206 readOnly: true
207 {{- end }}
208 {{- if .Values.controller.extraVolumeMounts }}
209 {{- toYaml .Values.controller.extraVolumeMounts | nindent 12 }}
210 {{- end }}
211 {{- end }}
212 {{- if .Values.controller.resources }}
213 resources: {{ toYaml .Values.controller.resources | nindent 12 }}
214 {{- end }}
215 {{- if .Values.controller.extraContainers }}
216 {{ toYaml .Values.controller.extraContainers | nindent 8 }}
217 {{- end }}
218 {{- if .Values.controller.extraInitContainers }}
219 initContainers: {{ toYaml .Values.controller.extraInitContainers | nindent 8 }}
220 {{- end }}
221 {{- if .Values.controller.hostNetwork }}
222 hostNetwork: {{ .Values.controller.hostNetwork }}
223 {{- end }}
224 {{- if .Values.controller.nodeSelector }}
225 nodeSelector: {{ toYaml .Values.controller.nodeSelector | nindent 8 }}
226 {{- end }}
227 {{- if .Values.controller.tolerations }}
228 tolerations: {{ toYaml .Values.controller.tolerations | nindent 8 }}
229 {{- end }}
230 {{- if .Values.controller.affinity }}
231 affinity: {{ toYaml .Values.controller.affinity | nindent 8 }}
232 {{- end }}
233 {{- if .Values.controller.topologySpreadConstraints }}
234 topologySpreadConstraints: {{ toYaml .Values.controller.topologySpreadConstraints | nindent 8 }}
235 {{- end }}
236 serviceAccountName: {{ template "ingress-nginx.serviceAccountName" . }}
237 terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
238 {{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraVolumes) }}
239 volumes:
240 {{- if .Values.controller.customTemplate.configMapName }}
241 - name: nginx-template-volume
242 configMap:
243 name: {{ .Values.controller.customTemplate.configMapName }}
244 items:
245 - key: {{ .Values.controller.customTemplate.configMapKey }}
246 path: nginx.tmpl
247 {{- end }}
248 {{- if .Values.controller.admissionWebhooks.enabled }}
249 - name: webhook-cert
250 secret:
251 secretName: {{ include "ingress-nginx.fullname" . }}-admission
252 {{- end }}
253 {{- if .Values.controller.extraVolumes }}
254 {{ toYaml .Values.controller.extraVolumes | nindent 8 }}
255 {{- end }}
256 {{- end }}
257{{- end }}