Add support for prometheus
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / templates / deployment.yaml
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4   name: {{ template "kong.fullname" . }}
5   labels:
6     {{- include "kong.metaLabels" . | nindent 4 }}
7     app.kubernetes.io/component: app
8 spec:
9   replicas: {{ .Values.replicaCount }}
10   selector:
11     matchLabels:
12       {{- include "kong.selectorLabels" . | nindent 6 }}
13   {{- if .Values.updateStrategy }}
14   strategy:
15 {{ toYaml .Values.updateStrategy | indent 4 }}
16   {{- end }}
17
18   template:
19     metadata:
20       annotations:
21         {{- if .Values.ingressController.admissionWebhook.enabled }}
22         checksum/admission-webhook.yaml: {{ include (print $.Template.BasePath "/admission-webhook.yaml") . | sha256sum }}
23         {{- end }}
24         {{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off" )) }}
25         {{- if .Values.dblessConfig.config }}
26         checksum/dbless.config: {{ toYaml .Values.dblessConfig.config | sha256sum }}
27         {{- end }}
28         {{- end }}
29         {{- if .Values.podAnnotations }}
30 {{ toYaml .Values.podAnnotations | indent 8 }}
31         {{- end }}
32         {{- if $.Values.global }}
33           {{- if $.Values.global.danm_networks }}
34             {{- $networklist := list }}
35             {{- range $network := $.Values.global.danm_networks }}
36               {{- if $network.tenants }}
37                 {{- if $network.tenants.kong }}
38                   {{- $networklist = append $networklist $network }}
39                 {{- end }}
40               {{- end }}
41             {{- end }}
42             {{- if $networklist }}
43         danm.k8s.io/interfaces: |
44           [
45             {{- range $network := $networklist }}
46               {{- printf "\n            {\"clusterNetwork\": \"%s\"" $network.name }}
47               {{- if $network.tenants.kong.ip }}
48                 {{- printf ", \"ip\": \"%s\"" $network.tenants.kong.ip }}
49               {{- else }}
50                 {{- printf ", \"ip\": \"dynamic\"" }}
51               {{- end }}
52               {{- if $network.tenants.kong.ip6 }}
53                 {{- printf ", \"ip6\": \"%s\"" $network.tenants.kong.ip6 }}
54               {{- end }}
55               {{- if $network.tenants.kong.proutes }}
56                 {{- printf ", \"proutes\": {" }}
57                 {{- range $subnet, $gw := $network.tenants.kong.proutes }}
58                   {{- if eq $subnet ( first ( keys $network.tenants.kong.proutes ))}}
59                     {{- printf "\"%s\": \"%s\"" $subnet $gw }}
60                   {{- else }}
61                     {{- printf ", \"%s\": \"%s\"" $subnet $gw }}
62                   {{- end }}
63                 {{- end }}
64                 {{- printf "}" }}
65               {{- end }}
66               {{- if ne $network.name (last $networklist).name }}
67               {{- printf "}," }}
68               {{- else }}
69               {{- printf "}" }}
70               {{- end }}
71             {{- end }}
72           ] 
73             {{- end }}
74           {{- end }}
75         {{- end }}
76       labels:
77         {{- include "kong.metaLabels" . | nindent 8 }}
78         app.kubernetes.io/component: app
79     spec:
80       {{- if or .Values.ingressController.enabled .Values.podSecurityPolicy.enabled }}
81       serviceAccountName: {{ template "kong.serviceAccountName" . }}
82       {{ end }}
83       {{- if .Values.image.pullSecrets }}
84       imagePullSecrets:
85       {{- range .Values.image.pullSecrets }}
86         - name: {{ . }}
87       {{- end }}
88       {{- end }}
89       {{- if not (eq .Values.env.database "off") }}
90       initContainers:
91       {{- include "kong.wait-for-db" . | nindent 6 }}
92       {{ end }}
93       containers:
94       {{- if .Values.ingressController.enabled }}
95       {{- include "kong.controller-container" . | nindent 6 }}
96       {{ end }}
97       - name: "proxy"
98         image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
99         imagePullPolicy: {{ .Values.image.pullPolicy }}
100         env:
101         {{- include "kong.final_env" . | nindent 8 }}
102         lifecycle:
103           preStop:
104             exec:
105               command: [ "/bin/sh", "-c", "kong quit" ]
106         ports:
107         - name: admin
108           containerPort: {{ .Values.admin.containerPort }}
109           {{- if .Values.admin.hostPort }}
110           hostPort: {{ .Values.admin.hostPort }}
111           {{- end}}
112           protocol: TCP
113         {{- if .Values.proxy.http.enabled }}
114         - name: proxy
115           containerPort: {{ .Values.proxy.http.containerPort }}
116           {{- if .Values.proxy.http.hostPort }}
117           hostPort: {{ .Values.proxy.http.hostPort }}
118           {{- end}}
119           protocol: TCP
120         {{- end }}
121         {{- if .Values.proxy.tls.enabled }}
122         - name: proxy-tls
123           containerPort: {{ .Values.proxy.tls.containerPort }}
124           {{- if .Values.proxy.tls.hostPort }}
125           hostPort: {{ .Values.proxy.tls.hostPort }}
126           {{- end}}
127           protocol: TCP
128         {{- end }}
129         - name: metrics
130           containerPort: 9542
131           protocol: TCP
132         {{- if .Values.ingressController.admissionWebhook.enabled }}
133         - name: webhook
134           containerPort: {{ .Values.ingressController.admissionWebhook.port }}
135           protocol: TCP
136         {{- end }}
137         {{- if .Values.enterprise.enabled }}
138         {{- if .Values.manager.http.enabled }}
139         - name: manager
140           containerPort: {{ .Values.manager.http.containerPort }}
141           {{- if .Values.manager.http.hostPort }}
142           hostPort: {{ .Values.manager.http.hostPort }}
143           {{- end}}
144           protocol: TCP
145         {{- end }}
146         {{- if .Values.manager.tls.enabled }}
147         - name: manager-tls
148           containerPort: {{ .Values.manager.tls.containerPort }}
149           {{- if .Values.manager.tls.hostPort }}
150           hostPort: {{ .Values.manager.tls.hostPort }}
151           {{- end}}
152           protocol: TCP
153         {{- end }}
154         {{- if .Values.portal.http.enabled }}
155         - name: portal
156           containerPort: {{ .Values.portal.http.containerPort }}
157           {{- if .Values.portal.http.hostPort }}
158           hostPort: {{ .Values.portal.http.hostPort }}
159           {{- end}}
160           protocol: TCP
161         {{- end }}
162         {{- if .Values.portal.tls.enabled }}
163         - name: portal-tls
164           containerPort: {{ .Values.portal.tls.containerPort }}
165           {{- if .Values.portal.tls.hostPort }}
166           hostPort: {{ .Values.portal.tls.hostPort }}
167           {{- end}}
168           protocol: TCP
169         {{- end }}
170         {{- if .Values.portalapi.http.enabled }}
171         - name: portalapi
172           containerPort: {{ .Values.portalapi.http.containerPort }}
173           {{- if .Values.portalapi.http.hostPort }}
174           hostPort: {{ .Values.portalapi.http.hostPort }}
175           {{- end}}
176           protocol: TCP
177         {{- end }}
178         {{- if .Values.portalapi.tls.enabled }}
179         - name: portalapi-tls
180           containerPort: {{ .Values.portalapi.tls.containerPort }}
181           {{- if .Values.portalapi.tls.hostPort }}
182           hostPort: {{ .Values.portalapi.tls.hostPort }}
183           {{- end}}
184           protocol: TCP
185         {{- end }}
186         {{- end }}
187         volumeMounts:
188         {{- include "kong.volumeMounts" . | nindent 10 }}
189         readinessProbe:
190 {{ toYaml .Values.readinessProbe | indent 10 }}
191         livenessProbe:
192 {{ toYaml .Values.livenessProbe | indent 10 }}
193         resources:
194 {{ toYaml .Values.resources | indent 10 }}
195     {{- if .Values.affinity }}
196       affinity:
197 {{ toYaml .Values.affinity | indent 8 }}
198     {{- end }}
199       securityContext:
200       {{- include "kong.podsecuritycontext" . | nindent 8 }}
201     {{- if .Values.nodeSelector }}
202       nodeSelector:
203 {{ toYaml .Values.nodeSelector | indent 8 }}
204     {{- end }}
205       tolerations:
206 {{ toYaml .Values.tolerations | indent 8 }}
207       volumes:
208       {{- include "kong.volumes" . | nindent 8 -}}