Fix bugs in AUX deployment
[it/dep.git] / ric-aux / 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               {{- printf "}" }}
67             {{- end }}
68           ] 
69             {{- end }}
70           {{- end }}
71         {{- end }}
72       labels:
73         {{- include "kong.metaLabels" . | nindent 8 }}
74         app.kubernetes.io/component: app
75     spec:
76       {{- if or .Values.ingressController.enabled .Values.podSecurityPolicy.enabled }}
77       serviceAccountName: {{ template "kong.serviceAccountName" . }}
78       {{ end }}
79       {{- if .Values.image.pullSecrets }}
80       imagePullSecrets:
81       {{- range .Values.image.pullSecrets }}
82         - name: {{ . }}
83       {{- end }}
84       {{- end }}
85       {{- if not (eq .Values.env.database "off") }}
86       initContainers:
87       {{- include "kong.wait-for-db" . | nindent 6 }}
88       {{ end }}
89       containers:
90       {{- if .Values.ingressController.enabled }}
91       {{- include "kong.controller-container" . | nindent 6 }}
92       {{ end }}
93       - name: "proxy"
94         image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
95         imagePullPolicy: {{ .Values.image.pullPolicy }}
96         env:
97         {{- include "kong.final_env" . | nindent 8 }}
98         lifecycle:
99           preStop:
100             exec:
101               command: [ "/bin/sh", "-c", "kong quit" ]
102         ports:
103         - name: admin
104           containerPort: {{ .Values.admin.containerPort }}
105           {{- if .Values.admin.hostPort }}
106           hostPort: {{ .Values.admin.hostPort }}
107           {{- end}}
108           protocol: TCP
109         {{- if .Values.proxy.http.enabled }}
110         - name: proxy
111           containerPort: {{ .Values.proxy.http.containerPort }}
112           {{- if .Values.proxy.http.hostPort }}
113           hostPort: {{ .Values.proxy.http.hostPort }}
114           {{- end}}
115           protocol: TCP
116         {{- end }}
117         {{- if .Values.proxy.tls.enabled }}
118         - name: proxy-tls
119           containerPort: {{ .Values.proxy.tls.containerPort }}
120           {{- if .Values.proxy.tls.hostPort }}
121           hostPort: {{ .Values.proxy.tls.hostPort }}
122           {{- end}}
123           protocol: TCP
124         {{- end }}
125         - name: metrics
126           containerPort: 9542
127           protocol: TCP
128         {{- if .Values.ingressController.admissionWebhook.enabled }}
129         - name: webhook
130           containerPort: {{ .Values.ingressController.admissionWebhook.port }}
131           protocol: TCP
132         {{- end }}
133         {{- if .Values.enterprise.enabled }}
134         {{- if .Values.manager.http.enabled }}
135         - name: manager
136           containerPort: {{ .Values.manager.http.containerPort }}
137           {{- if .Values.manager.http.hostPort }}
138           hostPort: {{ .Values.manager.http.hostPort }}
139           {{- end}}
140           protocol: TCP
141         {{- end }}
142         {{- if .Values.manager.tls.enabled }}
143         - name: manager-tls
144           containerPort: {{ .Values.manager.tls.containerPort }}
145           {{- if .Values.manager.tls.hostPort }}
146           hostPort: {{ .Values.manager.tls.hostPort }}
147           {{- end}}
148           protocol: TCP
149         {{- end }}
150         {{- if .Values.portal.http.enabled }}
151         - name: portal
152           containerPort: {{ .Values.portal.http.containerPort }}
153           {{- if .Values.portal.http.hostPort }}
154           hostPort: {{ .Values.portal.http.hostPort }}
155           {{- end}}
156           protocol: TCP
157         {{- end }}
158         {{- if .Values.portal.tls.enabled }}
159         - name: portal-tls
160           containerPort: {{ .Values.portal.tls.containerPort }}
161           {{- if .Values.portal.tls.hostPort }}
162           hostPort: {{ .Values.portal.tls.hostPort }}
163           {{- end}}
164           protocol: TCP
165         {{- end }}
166         {{- if .Values.portalapi.http.enabled }}
167         - name: portalapi
168           containerPort: {{ .Values.portalapi.http.containerPort }}
169           {{- if .Values.portalapi.http.hostPort }}
170           hostPort: {{ .Values.portalapi.http.hostPort }}
171           {{- end}}
172           protocol: TCP
173         {{- end }}
174         {{- if .Values.portalapi.tls.enabled }}
175         - name: portalapi-tls
176           containerPort: {{ .Values.portalapi.tls.containerPort }}
177           {{- if .Values.portalapi.tls.hostPort }}
178           hostPort: {{ .Values.portalapi.tls.hostPort }}
179           {{- end}}
180           protocol: TCP
181         {{- end }}
182         {{- end }}
183         volumeMounts:
184         {{- include "kong.volumeMounts" . | nindent 10 }}
185         readinessProbe:
186 {{ toYaml .Values.readinessProbe | indent 10 }}
187         livenessProbe:
188 {{ toYaml .Values.livenessProbe | indent 10 }}
189         resources:
190 {{ toYaml .Values.resources | indent 10 }}
191     {{- if .Values.affinity }}
192       affinity:
193 {{ toYaml .Values.affinity | indent 8 }}
194     {{- end }}
195       securityContext:
196       {{- include "kong.podsecuritycontext" . | nindent 8 }}
197     {{- if .Values.nodeSelector }}
198       nodeSelector:
199 {{ toYaml .Values.nodeSelector | indent 8 }}
200     {{- end }}
201       tolerations:
202 {{ toYaml .Values.tolerations | indent 8 }}
203       volumes:
204       {{- include "kong.volumes" . | nindent 8 -}}