/
gateway-deployment.yaml
321 lines (321 loc) · 15.7 KB
/
gateway-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
{{- if .Values.gateway.enabled -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ditto.fullname" . }}-gateway
labels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-gateway
{{ include "ditto.labels" . | indent 4 }}
spec:
replicas: {{ .Values.gateway.replicaCount }}
strategy:
{{- with .Values.gateway.updateStrategy }}
{{- toYaml . | nindent 4 }}
{{- end }}
minReadySeconds: {{ .Values.gateway.minReadySeconds }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-gateway
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-gateway
app.kubernetes.io/instance: {{ .Release.Name }}
actorSystemName: {{ .Values.pekko.actorSystemName }}
{{- with .Values.gateway.additionalLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.global.prometheus.enabled }}
prometheus.io/scrape: "true"
prometheus.io/path: "{{ .Values.global.prometheus.path }}"
prometheus.io/port: "{{ .Values.global.prometheus.port }}"
{{- end }}
checksum/password-config: {{ include (print $.Template.BasePath "/gateway-secret.yaml") . | sha256sum }}
checksum/mongodb-config: {{ include (print $.Template.BasePath "/mongodb-secret.yaml") . | sha256sum }}
{{- with .Values.gateway.additionalAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.rbac.enabled }}
serviceAccountName: {{ template "ditto.serviceAccountName" . }}
{{- end }}
{{- with .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
fsGroup: 1000
initContainers:
{{- if .Values.global.logging.logFiles.enabled }}
- name: change-volume-owner
image: busybox
securityContext:
runAsUser: 0
command: [ "sh", "-c", "chown -R 1000:1000 /var/log/ditto && echo 'changed ownership of /var/log/ditto to 1000:1000'" ]
volumeMounts:
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.gateway.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.gateway.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.gateway.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-gateway
containers:
- name: {{ .Chart.Name }}-gateway
image: {{ printf "%s:%s" .Values.gateway.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.gateway.image.tag ) ) }}
imagePullPolicy: {{ .Values.gateway.image.pullPolicy }}
env:
{{- if not .Values.global.logging.customConfigFile.enabled }}
- name: DITTO_LOGGING_DISABLE_SYSOUT_LOG
value: "{{ printf "%t" .Values.global.logging.sysout.enabled }}"
- name: DITTO_LOGGING_FILE_APPENDER
value: "{{ printf "%t" .Values.global.logging.logFiles.enabled }}"
{{- end }}
- name: DITTO_METRICS_METRIC_PREFIX
value: "{{ .Values.global.metrics.metricsPrefix }}"
- name: SYSTEM_METRICS_ENABLED
value: "{{ .Values.global.metrics.systemMetrics.enabled }}"
- name: DITTO_TRACING_ENABLED
value: "{{ .Values.global.tracing.enabled }}"
- name: DITTO_TRACING_OTEL_TRACE_REPORTER_ENABLED
value: "{{ .Values.global.tracing.otelTraceReporterEnabled }}"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "{{ tpl .Values.global.tracing.otelExporterOtlpEndpoint . }}"
- name: DITTO_TRACING_SAMPLER
value: "{{ .Values.global.tracing.sampler }}"
- name: DITTO_TRACING_RANDOM_SAMPLER_PROBABILITY
value: "{{ .Values.global.tracing.randomSampler.probability }}"
- name: DITTO_TRACING_ADAPTIVE_SAMPLER_THROUGHPUT
value: "{{ .Values.global.tracing.adaptiveSampler.throughput }}"
{{- if .Values.global.logging.logstash.enabled }}
- name: DITTO_LOGGING_LOGSTASH_SERVER
value: "{{ .Values.global.logging.logstash.endpoint }}"
{{- end }}
- name: POD_LABEL_SELECTOR
value: "app.kubernetes.io/name=%s"
- name: POD_NAMESPACE
value: {{ .Release.Namespace }}
- name: INSTANCE_INDEX
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: HOSTNAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: DISCOVERY_METHOD
value: "kubernetes-api"
- name: TZ
value: "{{ .Values.global.timezone }}"
- name: JAVA_TOOL_OPTIONS
value: >
{{ .Values.global.jvmOptions }}
-XX:ActiveProcessorCount={{ .Values.gateway.jvm.activeProcessorCount }}
-XX:MaxRAMPercentage={{ .Values.gateway.jvm.heapRamPercentage }}
-XX:InitialRAMPercentage={{ .Values.gateway.jvm.heapRamPercentage }}
-XX:MaxGCPauseMillis={{ .Values.gateway.jvm.maxGcPauseMillis }}
{{ .Values.gateway.additionalJvmOptions }}
{{ .Values.global.pekkoOptions }}
{{- if .Values.global.logging.customConfigFile.enabled }}
-Dlogback.configurationFile=/opt/ditto/{{ .Values.global.logging.customConfigFile.fileName }}
{{- end }}
{{- range $key, $value := .Values.gateway.config.authentication.oauth.openidConnectIssuers }}
"{{ printf "%s%s%s=%s" "-Dditto.gateway.authentication.oauth.openid-connect-issuers." $key ".issuer" $value.issuer }}"
{{- range $index, $subject := $value.authSubjects }}
"{{ printf "%s%s%s%d=%s" "-Dditto.gateway.authentication.oauth.openid-connect-issuers." $key ".auth-subjects." $index $subject }}"
{{- end }}
{{- end }}
{{- range $key, $value := .Values.gateway.config.authentication.devops.oauth.openidConnectIssuers }}
"{{ printf "%s%s%s=%s" "-Dditto.gateway.authentication.devops.oauth.openid-connect-issuers." $key ".issuer" $value.issuer }}"
{{- range $index, $subject := $value.authSubjects }}
"{{ printf "%s%s%s%d=%s" "-Dditto.gateway.authentication.devops.oauth.openid-connect-issuers." $key ".auth-subjects." $index $subject }}"
{{- end }}
{{- end }}
{{ join " " .Values.gateway.systemProps }}
- name: CLUSTER_BS_REQUIRED_CONTACTS
value: "{{ .Values.global.cluster.requiredContactPoints }}"
- name: DITTO_DDATA_NUMBER_OF_SHARDS
value: "{{ .Values.global.cluster.ddata.numberOfShards }}"
- name: DITTO_DDATA_MAX_DELTA_ELEMENTS
value: "{{ .Values.global.cluster.ddata.maxDeltaElements }}"
- name: CLUSTER_NUMBER_OF_SHARDS
value: "{{ .Values.global.cluster.numberOfShards }}"
- name: CLUSTER_DOWNING_STABLE_AFTER
value: "{{ .Values.global.cluster.downingStableAfter }}"
- name: CLUSTER_DOWNING_DOWN_ALL_WHEN_UNSTABLE
value: "{{ .Values.global.cluster.downAllWhenUnstable }}"
{{- if .Values.global.prometheus.enabled }}
- name: PROMETHEUS_PORT
value: "{{ .Values.global.prometheus.port }}"
{{- end }}
- name: REMOTE_MAX_FRAMESIZE
value: "{{ .Values.global.limits.clusterMaxFramesize }}"
- name: LIMITS_THINGS_MAX_SIZE
value: "{{ .Values.global.limits.thingsMaxSize }}"
- name: LIMITS_POLICIES_MAX_SIZE
value: "{{ .Values.global.limits.policiesMaxSize }}"
- name: LIMITS_POLICIES_MAX_IMPORTS
value: "{{ .Values.global.limits.policiesMaxImports }}"
- name: LIMITS_MESSAGES_MAX_SIZE
value: "{{ .Values.global.limits.messagesMaxSize }}"
- name: LIMITS_MESSAGES_HEADERS_SIZE
value: "{{ .Values.global.limits.maxHeadersSize }}"
- name: LIMITS_MESSAGES_AUTH_SUBJECTS_COUNT
value: "{{ .Values.global.limits.maxAuthSubjectsCount }}"
- name: ENABLE_PRE_AUTHENTICATION
value: "{{ or .Values.gateway.config.authentication.enablePreAuthentication (not .Values.global.jwtOnly) }}"
- name: DEVOPS_SECURED
value: "{{ .Values.gateway.config.authentication.devops.secured }}"
- name: DEVOPS_AUTHENTICATION_METHOD
value: "{{ .Values.gateway.config.authentication.devops.authMethod }}"
- name: DEVOPS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.gateway.config.authentication.devops.existingSecret | default ( printf "%s-gateway-secret" ( include "ditto.fullname" . )) }}
key: devops-password
{{- range $index, $oauthSubject := .Values.gateway.config.authentication.devops.oauthSubjects }}
- name: DEVOPS_OAUTH2_SUBJECTS.{{ $index }}
value: "{{ $oauthSubject }}"
{{- end }}
- name: DEVOPS_STATUS_SECURED
value: "{{ .Values.gateway.config.authentication.devops.statusSecured }}"
- name: STATUS_AUTHENTICATION_METHOD
value: "{{ .Values.gateway.config.authentication.devops.statusAuthMethod }}"
- name: STATUS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.gateway.config.authentication.devops.existingSecret | default ( printf "%s-gateway-secret" ( include "ditto.fullname" . )) }}
key: status-password
{{- range $index, $oauthSubject := .Values.gateway.config.authentication.devops.statusOauthSubjects }}
- name: STATUS_OAUTH2_SUBJECTS.{{ $index }}
value: "{{ $oauthSubject }}"
{{- end }}
- name: WS_SUBSCRIBER_BACKPRESSURE
value: "{{ .Values.gateway.config.websocket.subscriber.backpressureQueueSize }}"
- name: WS_PUBLISHER_BACKPRESSURE
value: "{{ .Values.gateway.config.websocket.publisher.backpressureBufferSize }}"
- name: GATEWAY_WEBSOCKET_THROTTLING_ENABLED
value: "{{ .Values.gateway.config.websocket.throttling.enabled }}"
- name: GATEWAY_WEBSOCKET_THROTTLING_INTERVAL
value: "{{ .Values.gateway.config.websocket.throttling.interval }}"
- name: GATEWAY_WEBSOCKET_THROTTLING_LIMIT
value: "{{ .Values.gateway.config.websocket.throttling.limit }}"
- name: GATEWAY_SSE_THROTTLING_ENABLED
value: "{{ .Values.gateway.config.sse.throttling.enabled }}"
- name: GATEWAY_SSE_THROTTLING_INTERVAL
value: "{{ .Values.gateway.config.sse.throttling.interval }}"
- name: GATEWAY_SSE_THROTTLING_LIMIT
value: "{{ .Values.gateway.config.sse.throttling.limit }}"
- name: OAUTH_ALLOWED_CLOCK_SKEW
value: "{{ .Values.gateway.config.authentication.oauth.allowedClockSkew }}"
{{- if .Values.gateway.extraEnv }}
{{- toYaml .Values.gateway.extraEnv | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.gateway.service.port }}
protocol: TCP
- name: remoting
containerPort: {{ .Values.pekko.remoting.port }}
protocol: TCP
- name: management
containerPort: {{ .Values.pekko.mgmthttp.port }}
protocol: TCP
{{- if .Values.global.prometheus.enabled }}
- name: prometheus
protocol: TCP
containerPort: {{ .Values.global.prometheus.port }}
{{- end }}
readinessProbe:
httpGet:
port: management
path: /ready
initialDelaySeconds: {{ .Values.gateway.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.gateway.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.gateway.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.gateway.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.gateway.readinessProbe.failureThreshold }}
livenessProbe:
httpGet:
port: management
path: /alive
initialDelaySeconds: {{ .Values.gateway.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.gateway.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.gateway.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.gateway.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.gateway.livenessProbe.failureThreshold }}
volumeMounts:
{{- if .Values.global.logging.customConfigFile.enabled }}
- name: ditto-custom-log-config
mountPath: /opt/ditto/{{ .Values.global.logging.customConfigFile.fileName }}
subPath: {{ .Values.global.logging.customConfigFile.fileName }}
{{- end }}
{{- if .Values.global.logging.logFiles.enabled }}
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
resources:
requests:
cpu: {{ mulf .Values.gateway.resources.cpu 1000 }}m
memory: {{ .Values.gateway.resources.memoryMi }}Mi
limits:
# ## no cpu limit to avoid CFS scheduler limits
# ref: https://pekko.apache.org/docs/pekko/current/additional/deploying.html#deploying-to-kubernetes
# cpu: ""
memory: {{ .Values.gateway.resources.memoryMi }}Mi
{{- if .Values.openshift.enabled }}
{{- with .Values.openshift.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- else }}
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
allowPrivilegeEscalation: false
{{- end }}
priorityClassName: "{{ .Values.gateway.priorityClassName }}"
{{- with .Values.gateway.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gateway.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gateway.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.global.logging.customConfigFile.enabled }}
- name: ditto-custom-log-config
configMap:
name: {{ .Release.Name }}-logback-config-gateway-xml
{{- end }}
{{- if .Values.global.logging.logFiles.enabled }}
- name: ditto-log-files-directory
hostPath:
path: /var/log/ditto
type: DirectoryOrCreate
{{- end }}
{{- end }}