J release changes
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / templates / deployment.yaml
1 {{- if or .Values.deployment.kong.enabled .Values.ingressController.enabled }}
2 apiVersion: apps/v1
3 {{- if .Values.deployment.daemonset }}
4 kind: DaemonSet
5 {{- else }}
6 kind: Deployment
7 {{- end }}
8 metadata:
9   name: {{ template "kong.fullname" . }}
10   namespace:  {{ template "kong.namespace" . }}
11   labels:
12     {{- include "kong.metaLabels" . | nindent 4 }}
13     app.kubernetes.io/component: app
14   {{- if .Values.deploymentAnnotations }}
15   annotations:
16   {{- range $key, $value := .Values.deploymentAnnotations }}
17     {{ $key }}: {{ include "kong.renderTpl" (dict "value" $value "context" $) | quote }}
18   {{- end }}
19   {{- end }}
20 spec:
21   {{- if not .Values.autoscaling.enabled }}
22   {{- if not .Values.deployment.daemonset }}
23   replicas: {{ .Values.replicaCount }}
24   {{- end }}
25   {{- end }}
26   selector:
27     matchLabels:
28       {{- include "kong.selectorLabels" . | nindent 6 }}
29   {{- if .Values.updateStrategy }}
30   {{- if .Values.deployment.daemonset }}
31   updateStrategy:
32   {{- else }}
33   strategy:
34   {{- end }}
35 {{ toYaml .Values.updateStrategy | indent 4 }}
36   {{- end }}
37   {{- if .Values.deployment.minReadySeconds }}
38   minReadySeconds: {{ .Values.deployment.minReadySeconds }}
39   {{- end }}
40
41   template:
42     metadata:
43       annotations:
44         {{- if (and (not .Values.deployment.serviceAccount.automountServiceAccountToken) (or .Values.deployment.serviceAccount.create .Values.deployment.serviceAccount.name)) }}
45         kuma.io/service-account-token-volume: {{ template "kong.serviceAccountTokenName" . }}
46         {{- end }}
47         {{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off" )) }}
48         {{- if .Values.dblessConfig.config }}
49         checksum/dbless.config: {{ toYaml .Values.dblessConfig.config | sha256sum }}
50         {{- end }}
51         {{- end }}
52         {{- if .Values.podAnnotations }}
53         {{- range $key, $value := .Values.podAnnotations }}
54         {{ $key }}: {{ include "kong.renderTpl" (dict "value" $value "context" $) | quote }}
55         {{- end }}
56         {{- end }}
57       labels:
58         {{- include "kong.metaLabels" . | nindent 8 }}
59         app.kubernetes.io/component: app
60         app: {{ template "kong.fullname" . }}
61         version: {{ .Chart.AppVersion | quote }}
62         {{- if .Values.podLabels }}
63         {{ include "kong.renderTpl" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
64         {{- end }}
65     spec:
66       {{- if .Values.deployment.hostname }}
67       hostname: {{ .Values.deployment.hostname }}
68       {{- end }}
69       {{- if .Values.deployment.hostNetwork }}
70       hostNetwork: true
71       {{- end }}
72       {{- if .Values.priorityClassName }}
73       priorityClassName: "{{ .Values.priorityClassName }}"
74       {{- end }}
75       {{- if or .Values.deployment.serviceAccount.create .Values.deployment.serviceAccount.name }}
76       serviceAccountName: {{ template "kong.serviceAccountName" . }}
77       {{- end }}
78       {{- if (and (or .Values.deployment.serviceAccount.create .Values.deployment.serviceAccount.name) .Values.deployment.serviceAccount.automountServiceAccountToken) }}
79       automountServiceAccountToken: true
80       {{- else }}
81       automountServiceAccountToken: false
82       {{ end }}
83       {{- if .Values.image.pullSecrets }}
84       imagePullSecrets:
85       {{- range .Values.image.pullSecrets }}
86         - name: {{ . }}
87       {{- end }}
88       {{- end }}
89       {{- if .Values.deployment.kong.enabled }}
90       initContainers:
91       - name: clear-stale-pid
92         image: {{ include "kong.getRepoTag" .Values.image }}
93         imagePullPolicy: {{ .Values.image.pullPolicy }}
94         securityContext:
95         {{ toYaml .Values.containerSecurityContext | nindent 10 }}
96         resources:
97 {{ toYaml .Values.resources | indent 10 }}
98         command:
99         - "rm"
100         - "-vrf"
101         - "$KONG_PREFIX/pids"
102         env:
103         {{- include "kong.env" . | nindent 8 }}
104         {{- include "kong.envFrom" .Values.envFrom | nindent 8 }}
105         volumeMounts:
106         {{- include "kong.volumeMounts" . | nindent 8 }}
107         {{- if .Values.deployment.initContainers }}
108         {{- toYaml .Values.deployment.initContainers | nindent 6 }}
109         {{- end }}
110         {{- if (and (not (eq .Values.env.database "off")) .Values.waitImage.enabled) }}
111         {{- include "kong.wait-for-db" . | nindent 6 }}
112         {{- end }}
113       {{- end }}
114       {{- if .Values.deployment.hostAliases }}
115       hostAliases:
116         {{- toYaml .Values.deployment.hostAliases | nindent 6 }}
117       {{- end}}
118       {{- if .Values.dnsPolicy }}
119       dnsPolicy: {{ .Values.dnsPolicy | quote }}
120       {{- end }}
121       {{- if .Values.dnsConfig }}
122       dnsConfig:
123 {{ toYaml .Values.dnsConfig | indent 8 }}
124       {{- end }}
125       containers:
126       {{- if .Values.ingressController.enabled }}
127       {{- include "kong.controller-container" . | nindent 6 }}
128       {{ end }}
129       {{- if .Values.deployment.sidecarContainers }}
130       {{- toYaml .Values.deployment.sidecarContainers | nindent 6 }}
131       {{- end }}
132       {{- if .Values.deployment.kong.enabled }}
133       - name: "proxy"
134         image: {{ include "kong.getRepoTag" .Values.image }}
135         imagePullPolicy: {{ .Values.image.pullPolicy }}
136         securityContext:
137         {{ toYaml .Values.containerSecurityContext | nindent 10 }}
138         env:
139         {{- include "kong.no_daemon_env" . | nindent 8 }}
140         {{- include "kong.envFrom" .Values.envFrom | nindent 8 }}
141         lifecycle:
142           {{- toYaml .Values.lifecycle | nindent 10 }}
143         ports:
144         {{- if (and .Values.admin.http.enabled .Values.admin.enabled) }}
145         - name: admin
146           containerPort: {{ .Values.admin.http.containerPort }}
147           {{- if .Values.admin.http.hostPort }}
148           hostPort: {{ .Values.admin.http.hostPort }}
149           {{- end}}
150           protocol: TCP
151         {{- end }}
152         {{- if (and .Values.admin.tls.enabled .Values.admin.enabled) }}
153         - name: admin-tls
154           containerPort: {{ .Values.admin.tls.containerPort }}
155           {{- if .Values.admin.tls.hostPort }}
156           hostPort: {{ .Values.admin.tls.hostPort }}
157           {{- end}}
158           protocol: TCP
159         {{- end }}
160         {{- if (and .Values.proxy.http.enabled .Values.proxy.enabled) }}
161         - name: proxy
162           containerPort: {{ .Values.proxy.http.containerPort }}
163           {{- if .Values.proxy.http.hostPort }}
164           hostPort: {{ .Values.proxy.http.hostPort }}
165           {{- end}}
166           protocol: TCP
167         {{- end }}
168         {{- if (and .Values.proxy.tls.enabled .Values.proxy.enabled)}}
169         - name: proxy-tls
170           containerPort: {{ .Values.proxy.tls.containerPort }}
171           {{- if .Values.proxy.tls.hostPort }}
172           hostPort: {{ .Values.proxy.tls.hostPort }}
173           {{- end}}
174           protocol: TCP
175         {{- end }}
176         {{- range .Values.proxy.stream }}
177         - name: stream{{ if (eq (default "TCP" .protocol) "UDP") }}udp{{ end }}-{{ .containerPort }}
178           containerPort: {{ .containerPort }}
179           {{- if .hostPort }}
180           hostPort: {{ .hostPort }}
181           {{- end}}
182           protocol: {{ .protocol }}
183         {{- end }}
184         {{- range .Values.udpProxy.stream }}
185         - name: streamudp-{{ .containerPort }}
186           containerPort: {{ .containerPort }}
187           {{- if .hostPort }}
188           hostPort: {{ .hostPort }}
189           {{- end}}
190           protocol: {{ .protocol }}
191         {{- end }}
192         {{- if (and .Values.status.http.enabled .Values.status.enabled)}}
193         - name: status
194           containerPort: {{ .Values.status.http.containerPort }}
195           {{- if .Values.status.http.hostPort }}
196           hostPort: {{ .Values.status.http.hostPort }}
197           {{- end}}
198           protocol: TCP
199         {{- end }}
200         {{- if (and .Values.status.tls.enabled .Values.status.enabled) }}
201         - name: status-tls
202           containerPort: {{ .Values.status.tls.containerPort }}
203           {{- if .Values.status.tls.hostPort }}
204           hostPort: {{ .Values.status.tls.hostPort }}
205           {{- end}}
206           protocol: TCP
207         {{- end }}
208         {{- if (and .Values.cluster.tls.enabled .Values.cluster.enabled) }}
209         - name: cluster-tls
210           containerPort: {{ .Values.cluster.tls.containerPort }}
211           {{- if .Values.cluster.tls.hostPort }}
212           hostPort: {{ .Values.cluster.tls.hostPort }}
213           {{- end}}
214           protocol: TCP
215         {{- end }}
216         {{- if .Values.enterprise.enabled }}
217         {{- if (and .Values.manager.http.enabled .Values.manager.enabled) }}
218         - name: manager
219           containerPort: {{ .Values.manager.http.containerPort }}
220           {{- if .Values.manager.http.hostPort }}
221           hostPort: {{ .Values.manager.http.hostPort }}
222           {{- end}}
223           protocol: TCP
224         {{- end }}
225         {{- if (and .Values.manager.tls.enabled .Values.manager.enabled) }}
226         - name: manager-tls
227           containerPort: {{ .Values.manager.tls.containerPort }}
228           {{- if .Values.manager.tls.hostPort }}
229           hostPort: {{ .Values.manager.tls.hostPort }}
230           {{- end}}
231           protocol: TCP
232         {{- end }}
233         {{- if (and .Values.portal.http.enabled .Values.portal.enabled) }}
234         - name: portal
235           containerPort: {{ .Values.portal.http.containerPort }}
236           {{- if .Values.portal.http.hostPort }}
237           hostPort: {{ .Values.portal.http.hostPort }}
238           {{- end}}
239           protocol: TCP
240         {{- end }}
241         {{- if (and .Values.portal.tls.enabled .Values.portal.enabled) }}
242         - name: portal-tls
243           containerPort: {{ .Values.portal.tls.containerPort }}
244           {{- if .Values.portal.tls.hostPort }}
245           hostPort: {{ .Values.portal.tls.hostPort }}
246           {{- end}}
247           protocol: TCP
248         {{- end }}
249         {{- if (and .Values.portalapi.http.enabled .Values.portalapi.enabled) }}
250         - name: portalapi
251           containerPort: {{ .Values.portalapi.http.containerPort }}
252           {{- if .Values.portalapi.http.hostPort }}
253           hostPort: {{ .Values.portalapi.http.hostPort }}
254           {{- end}}
255           protocol: TCP
256         {{- end }}
257         {{- if (and .Values.portalapi.tls.enabled .Values.portalapi.enabled) }}
258         - name: portalapi-tls
259           containerPort: {{ .Values.portalapi.tls.containerPort }}
260           {{- if .Values.portalapi.tls.hostPort }}
261           hostPort: {{ .Values.portalapi.tls.hostPort }}
262           {{- end}}
263           protocol: TCP
264         {{- end }}
265         {{- if (and .Values.clustertelemetry.tls.enabled .Values.clustertelemetry.enabled) }}
266         - name: clustert-tls
267           containerPort: {{ .Values.clustertelemetry.tls.containerPort }}
268           {{- if .Values.clustertelemetry.tls.hostPort }}
269           hostPort: {{ .Values.clustertelemetry.tls.hostPort }}
270           {{- end}}
271           protocol: TCP
272         {{- end }}
273         {{- end }}
274         volumeMounts:
275         {{- include "kong.volumeMounts" . | nindent 10 }}
276         {{- include "kong.userDefinedVolumeMounts" .Values.deployment | nindent 10 }}
277         readinessProbe:
278 {{ include "kong.proxy.compatibleReadiness" . | indent 10 }}
279         livenessProbe:
280 {{ toYaml .Values.livenessProbe | indent 10 }}
281         {{- if .Values.startupProbe }}
282         startupProbe:
283 {{ toYaml .Values.startupProbe | indent 10 }}
284         {{- end }}
285         resources:
286 {{ toYaml .Values.resources | indent 10 }}
287         {{- end }} {{/* End of Kong container spec */}}
288     {{- if .Values.affinity }}
289       affinity:
290 {{ toYaml .Values.affinity | indent 8 }}
291     {{- end }}
292     {{- if .Values.topologySpreadConstraints }}
293       topologySpreadConstraints:
294 {{ toYaml .Values.topologySpreadConstraints | indent 8 }}
295     {{- end }}
296       securityContext:
297       {{- include "kong.podsecuritycontext" . | nindent 8 }}
298     {{- if .Values.nodeSelector }}
299       nodeSelector:
300 {{ toYaml .Values.nodeSelector | indent 8 }}
301     {{- end }}
302       terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
303     {{- if .Values.tolerations }}
304       tolerations:
305 {{ toYaml .Values.tolerations | indent 8 }}
306     {{- end }}
307       volumes:
308       {{- include "kong.volumes" . | nindent 8 -}}
309       {{- include "kong.userDefinedVolumes" . | nindent 8 -}}
310 {{- end }}