blob: 33824d58a6ff7027b23a45dc5cde6358ccfa7809 [file] [log] [blame]
gio07eb1082024-10-25 14:35:56 +04001{{- /*
2Copyright Broadcom, Inc. All Rights Reserved.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if (include "mongodb.hidden.enabled" .) }}
7{{- $replicaCount := int .Values.hidden.replicaCount }}
8{{- $loadBalancerIPListLength := len .Values.externalAccess.hidden.service.loadBalancerIPs }}
9{{- if not (and .Values.externalAccess.hidden.enabled (not .Values.externalAccess.autoDiscovery.enabled) (not (eq $replicaCount $loadBalancerIPListLength )) (eq .Values.externalAccess.hidden.service.type "LoadBalancer")) }}
10apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
11kind: StatefulSet
12metadata:
13 name: {{ printf "%s-hidden" (include "mongodb.fullname" .) }}
14 namespace: {{ include "mongodb.namespace" . | quote }}
15 {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.hidden.labels .Values.commonLabels ) "context" . ) }}
16 labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
17 app.kubernetes.io/component: hidden
18 {{- if or .Values.hidden.annotations .Values.commonAnnotations }}
19 {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.hidden.annotations .Values.commonAnnotations ) "context" . ) }}
20 annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
21 {{- end }}
22spec:
23 serviceName: {{ printf "%s-hidden-headless" (include "mongodb.fullname" .) }}
24 podManagementPolicy: {{ .Values.hidden.podManagementPolicy }}
25 replicas: {{ .Values.hidden.replicaCount }}
26 {{- if .Values.hidden.updateStrategy }}
27 updateStrategy: {{- toYaml .Values.hidden.updateStrategy | nindent 4 }}
28 {{- end }}
29 {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.hidden.podLabels .Values.commonLabels ) "context" . ) }}
30 selector:
31 matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
32 app.kubernetes.io/component: hidden
33 template:
34 metadata:
35 labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
36 app.kubernetes.io/component: hidden
37 {{- if or (include "mongodb.hidden.createConfigmap" .) .Values.hidden.podAnnotations }}
38 annotations:
39 {{- if (include "mongodb.hidden.createConfigmap" .) }}
40 checksum/configuration: {{ include (print $.Template.BasePath "/hidden/configmap.yaml") . | sha256sum }}
41 {{- end }}
42 {{- if .Values.hidden.podAnnotations }}
43 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.podAnnotations "context" $) | nindent 8 }}
44 {{- end }}
45 {{- end }}
46 spec:
47 {{- include "mongodb.imagePullSecrets" . | nindent 6 }}
48 {{- if .Values.hidden.schedulerName }}
49 schedulerName: {{ .Values.hidden.schedulerName | quote }}
50 {{- end }}
51 serviceAccountName: {{ template "mongodb.serviceAccountName" . }}
52 automountServiceAccountToken: {{ .Values.hidden.automountServiceAccountToken }}
53 {{- if .Values.hidden.hostAliases }}
54 hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.hostAliases "context" $) | nindent 8 }}
55 {{- end }}
56 {{- if .Values.hidden.affinity }}
57 affinity: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.affinity "context" $) | nindent 8 }}
58 {{- else }}
59 affinity:
60 podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.hidden.podAffinityPreset "component" "hidden" "customLabels" $podLabels "topologyKey" .Values.topologyKey "context" $) | nindent 10 }}
61 podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.hidden.podAntiAffinityPreset "component" "hidden" "customLabels" $podLabels "topologyKey" .Values.topologyKey "context" $) | nindent 10 }}
62 nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.hidden.nodeAffinityPreset.type "key" .Values.hidden.nodeAffinityPreset.key "values" .Values.hidden.nodeAffinityPreset.values) | nindent 10 }}
63 {{- end }}
64 {{- if .Values.hidden.nodeSelector }}
65 nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.nodeSelector "context" $) | nindent 8 }}
66 {{- end }}
67 {{- if .Values.hidden.tolerations }}
68 tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.tolerations "context" $) | nindent 8 }}
69 {{- end }}
70 {{- if .Values.hidden.topologySpreadConstraints }}
71 topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.topologySpreadConstraints "context" $) | nindent 8 }}
72 {{- end }}
73 {{- if .Values.hidden.priorityClassName }}
74 priorityClassName: {{ .Values.hidden.priorityClassName }}
75 {{- end }}
76 {{- if .Values.hidden.runtimeClassName }}
77 runtimeClassName: {{ .Values.hidden.runtimeClassName }}
78 {{- end }}
79 {{- if .Values.hidden.podSecurityContext.enabled }}
80 securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.hidden.podSecurityContext "context" $) | nindent 8 }}
81 {{- end }}
82 {{ if .Values.hidden.terminationGracePeriodSeconds }}
83 terminationGracePeriodSeconds: {{ .Values.hidden.terminationGracePeriodSeconds }}
84 {{- end }}
85 enableServiceLinks: {{ .Values.enableServiceLinks }}
86 initContainers:
87 {{- if .Values.hidden.initContainers }}
88 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.initContainers "context" $) | nindent 8 }}
89 {{- end }}
90 {{- if and .Values.volumePermissions.enabled .Values.hidden.persistence.enabled }}
91 {{- include "mongodb.initContainer.volumePermissions" . | indent 8 }}
92 {{- end }}
93 {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }}
94 {{- include "mongodb.initContainers.autoDiscovery" . | indent 8 }}
95 {{- end }}
96 {{- if and .Values.externalAccess.enabled ( or .Values.externalAccess.service.publicNames .Values.externalAccess.service.domain ) }}
97 {{- include "mongodb.initContainers.dnsCheck" . | indent 8 }}
98 {{- end }}
99 {{- include "mongodb.initContainer.prepareLogDir" . | nindent 8 }}
100 {{- if .Values.tls.enabled }}
101 - name: generate-tls-certs
102 image: {{ include "mongodb.tls.image" . }}
103 imagePullPolicy: {{ .Values.tls.image.pullPolicy | quote }}
104 env:
105 - name: MY_POD_NAMESPACE
106 valueFrom:
107 fieldRef:
108 fieldPath: metadata.namespace
109 - name: MY_POD_HOST_IP
110 valueFrom:
111 fieldRef:
112 fieldPath: status.hostIP
113 - name: MY_POD_NAME
114 valueFrom:
115 fieldRef:
116 fieldPath: metadata.name
117 volumeMounts:
118 {{- if (include "mongodb.autoGenerateCerts" .) }}
119 - name: certs-volume
120 mountPath: /certs/CAs
121 {{- else }}
122 {{- range $index, $_ := .Values.tls.hidden.existingSecrets }}
123 - name: mongodb-certs-{{ $index }}
124 mountPath: /certs-{{ $index }}
125 {{- end }}
126 {{- end }}
127 - name: certs
128 mountPath: /certs
129 - name: common-scripts
130 mountPath: /bitnami/scripts
131 - name: empty-dir
132 mountPath: /tmp
133 subPath: tmp-dir
134 command:
135 - /bitnami/scripts/generate-certs.sh
136 args:
137 - -s {{ printf "%s-hidden-headless" (include "mongodb.fullname" .) }}
138 {{- if .Values.externalAccess.hidden.service.loadBalancerIPs }}
139 - -i {{ join "," .Values.externalAccess.hidden.service.loadBalancerIPs }}
140 {{- end }}
141 {{- if or .Values.tls.extraDnsNames .Values.externalAccess.service.publicNames }}
142 - -n {{ join "," ( concat .Values.tls.extraDnsNames .Values.externalAccess.service.publicNames ) }}
143 {{- end }}
144 {{- if .Values.tls.resources }}
145 resources: {{- include "common.tplvalues.render" (dict "value" .Values.tls.resources "context" $) | nindent 12 }}
146 {{- else if ne .Values.tls.resourcesPreset "none" }}
147 resources: {{- include "common.resources.preset" (dict "type" .Values.tls.resourcesPreset) | nindent 12 }}
148 {{- end }}
149 {{- end }}
150 containers:
151 - name: mongodb
152 image: {{ include "mongodb.image" . }}
153 imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
154 {{- if .Values.hidden.containerSecurityContext.enabled }}
155 securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.hidden.containerSecurityContext "context" $) | nindent 12 }}
156 {{- end }}
157 {{- if .Values.diagnosticMode.enabled }}
158 command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
159 {{- else if .Values.hidden.command }}
160 command: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.command "context" $) | nindent 12 }}
161 {{- else }}
162 command:
163 - /scripts/setup-hidden.sh
164 {{- end }}
165 {{- if .Values.diagnosticMode.enabled }}
166 args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
167 {{- else if .Values.hidden.args }}
168 args: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.args "context" $) | nindent 12 }}
169 {{- end }}
170 {{- if .Values.hidden.lifecycleHooks }}
171 lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.lifecycleHooks "context" $) | nindent 12 }}
172 {{- end }}
173 env:
174 - name: BITNAMI_DEBUG
175 value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
176 {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }}
177 - name: SHARED_FILE
178 value: "/shared/info.txt"
179 {{- end }}
180 - name: MY_POD_NAME
181 valueFrom:
182 fieldRef:
183 fieldPath: metadata.name
184 - name: MY_POD_HOST_IP
185 valueFrom:
186 fieldRef:
187 fieldPath: status.hostIP
188 - name: MY_POD_NAMESPACE
189 valueFrom:
190 fieldRef:
191 fieldPath: metadata.namespace
192 - name: K8S_SERVICE_NAME
193 value: "{{ include "mongodb.service.nameOverride" . }}"
194 - name: K8S_HIDDEN_NODE_SERVICE_NAME
195 value: "{{ include "mongodb.fullname" . }}-hidden-headless"
196 - name: MONGODB_REPLICA_SET_MODE
197 value: "hidden"
198 - name: MONGODB_INITIAL_PRIMARY_HOST
199 value: {{ include "mongodb.initialPrimaryHost" . | quote }}
200 - name: MONGODB_REPLICA_SET_NAME
201 value: {{ .Values.replicaSetName | quote }}
202 {{- if and .Values.replicaSetHostnames (not .Values.externalAccess.hidden.enabled) }}
203 - name: MONGODB_ADVERTISED_HOSTNAME
204 value: "$(MY_POD_NAME).$(K8S_HIDDEN_NODE_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.{{ .Values.clusterDomain }}"
205 {{- end }}
206 {{- $customUsers := include "mongodb.customUsers" . -}}
207 {{- $customDatabases := include "mongodb.customDatabases" . -}}
208 {{- if not (empty $customUsers) }}
209 - name: MONGODB_EXTRA_USERNAMES
210 value: {{ $customUsers | quote }}
211 {{- end }}
212 {{- if not (empty $customDatabases) }}
213 - name: MONGODB_EXTRA_DATABASES
214 value: {{ $customDatabases | quote }}
215 {{- end }}
216 {{- if .Values.auth.enabled }}
217 {{- if and (not (empty $customUsers)) (not (empty $customDatabases)) }}
218 - name: MONGODB_EXTRA_PASSWORDS
219 valueFrom:
220 secretKeyRef:
221 name: {{ include "mongodb.secretName" . }}
222 key: mongodb-passwords
223 {{- end }}
224 - name: MONGODB_ROOT_USER
225 value: {{ .Values.auth.rootUser | quote }}
226 - name: MONGODB_ROOT_PASSWORD
227 valueFrom:
228 secretKeyRef:
229 name: {{ include "mongodb.secretName" . }}
230 key: mongodb-root-password
231 - name: MONGODB_REPLICA_SET_KEY
232 valueFrom:
233 secretKeyRef:
234 name: {{ include "mongodb.secretName" . }}
235 key: mongodb-replica-set-key
236 {{- end }}
237 {{- if and .Values.metrics.enabled (not (empty .Values.metrics.username)) }}
238 - name: MONGODB_METRICS_USERNAME
239 value: {{ .Values.metrics.username | quote }}
240 {{- if .Values.auth.enabled }}
241 - name: MONGODB_METRICS_PASSWORD
242 valueFrom:
243 secretKeyRef:
244 name: {{ include "mongodb.secretName" . }}
245 key: mongodb-metrics-password
246 {{- end }}
247 {{- end }}
248 - name: ALLOW_EMPTY_PASSWORD
249 value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
250 - name: MONGODB_SYSTEM_LOG_VERBOSITY
251 value: {{ .Values.systemLogVerbosity | quote }}
252 - name: MONGODB_DISABLE_SYSTEM_LOG
253 value: {{ ternary "yes" "no" .Values.disableSystemLog | quote }}
254 - name: MONGODB_DISABLE_JAVASCRIPT
255 value: {{ ternary "yes" "no" .Values.disableJavascript | quote }}
256 - name: MONGODB_ENABLE_JOURNAL
257 value: {{ ternary "yes" "no" .Values.enableJournal | quote }}
258 - name: MONGODB_PORT_NUMBER
259 value: {{ .Values.hidden.containerPorts.mongodb | quote }}
260 - name: MONGODB_ENABLE_IPV6
261 value: {{ ternary "yes" "no" .Values.enableIPv6 | quote }}
262 - name: MONGODB_ENABLE_DIRECTORY_PER_DB
263 value: {{ ternary "yes" "no" .Values.directoryPerDB | quote }}
264 {{- $extraFlags := .Values.hidden.extraFlags | join " " -}}
265 {{- if .Values.tls.enabled }}
266 {{- if .Values.tls.mTLS.enabled }}
267 {{- $extraFlags = printf "--tlsCAFile=/certs/mongodb-ca-cert %s" $extraFlags }}
268 {{- end }}
269 {{- $extraFlags = printf "--tlsMode=%s --tlsCertificateKeyFile=/certs/mongodb.pem %s" .Values.tls.mode $extraFlags }}
270 {{- end }}
271 {{- if ne $extraFlags "" }}
272 - name: MONGODB_EXTRA_FLAGS
273 value: {{ $extraFlags | quote }}
274 {{- end }}
275 {{- if .Values.tls.enabled }}
276 - name: MONGODB_CLIENT_EXTRA_FLAGS
277 value: --tls {{ if .Values.tls.mTLS.enabled }}--tlsCertificateKeyFile=/certs/mongodb.pem {{ end }}--tlsCAFile=/certs/mongodb-ca-cert
278 {{- end }}
279 {{- if .Values.hidden.extraEnvVars }}
280 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.extraEnvVars "context" $) | nindent 12 }}
281 {{- end }}
282 {{- if or .Values.hidden.extraEnvVarsCM .Values.hidden.extraEnvVarsSecret }}
283 envFrom:
284 {{- if .Values.hidden.extraEnvVarsCM }}
285 - configMapRef:
286 name: {{ tpl .Values.hidden.extraEnvVarsCM . | quote }}
287 {{- end }}
288 {{- if .Values.hidden.extraEnvVarsSecret }}
289 - secretRef:
290 name: {{ tpl .Values.hidden.extraEnvVarsSecret . | quote }}
291 {{- end }}
292 {{- end }}
293 ports:
294 - containerPort: {{ .Values.hidden.containerPorts.mongodb }}
295 name: mongodb
296 {{- if not .Values.diagnosticMode.enabled }}
297 {{- if .Values.hidden.customLivenessProbe }}
298 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.customLivenessProbe "context" $) | nindent 12 }}
299 {{- else if .Values.hidden.livenessProbe.enabled }}
300 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.hidden.livenessProbe "enabled") "context" $) | nindent 12 }}
301 exec:
302 command:
303 - /bitnami/scripts/ping-mongodb.sh
304 {{- end }}
305 {{- if .Values.hidden.customReadinessProbe }}
306 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.customReadinessProbe "context" $) | nindent 12 }}
307 {{- else if .Values.hidden.readinessProbe.enabled }}
308 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.hidden.readinessProbe "enabled") "context" $) | nindent 12 }}
309 exec:
310 command:
311 - /bitnami/scripts/readiness-probe.sh
312 {{- end }}
313 {{- if .Values.hidden.customStartupProbe }}
314 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.customStartupProbe "context" $) | nindent 12 }}
315 {{- else if .Values.hidden.startupProbe.enabled }}
316 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.hidden.startupProbe "enabled") "context" $) | nindent 12 }}
317 exec:
318 command:
319 - /bitnami/scripts/startup-probe.sh
320 {{- end }}
321 {{- end }}
322 {{- if .Values.hidden.resources }}
323 resources: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.resources "context" $) | nindent 12 }}
324 {{- else if ne .Values.hidden.resourcesPreset "none" }}
325 resources: {{- include "common.resources.preset" (dict "type" .Values.hidden.resourcesPreset) | nindent 12 }}
326 {{- end }}
327 volumeMounts:
328 - name: datadir
329 mountPath: {{ .Values.hidden.persistence.mountPath }}
330 subPath: {{ .Values.hidden.persistence.subPath }}
331 - name: common-scripts
332 mountPath: /bitnami/scripts
333 {{- if or .Values.initdbScriptsConfigMap .Values.initdbScripts }}
334 - name: custom-init-scripts
335 mountPath: /docker-entrypoint-initdb.d
336 {{- end }}
337 {{- if or .Values.hidden.configuration .Values.hidden.existingConfigmap }}
338 - name: config
339 mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
340 subPath: mongodb.conf
341 {{- end }}
342 - name: scripts
343 mountPath: /scripts/setup-hidden.sh
344 subPath: setup-hidden.sh
345 {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }}
346 - name: shared
347 mountPath: /shared
348 {{- end }}
349 {{- if .Values.tls.enabled }}
350 - name: certs
351 mountPath: /certs
352 {{- end }}
353 - name: empty-dir
354 mountPath: /tmp
355 subPath: tmp-dir
356 - name: empty-dir
357 mountPath: /opt/bitnami/mongodb/conf
358 subPath: app-conf-dir
359 - name: empty-dir
360 mountPath: /opt/bitnami/mongodb/tmp
361 subPath: app-tmp-dir
362 - name: empty-dir
363 mountPath: /opt/bitnami/mongodb/logs
364 subPath: app-logs-dir
365 - name: empty-dir
366 mountPath: /.mongodb
367 subPath: mongosh-home
368 {{- if .Values.hidden.extraVolumeMounts }}
369 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.extraVolumeMounts "context" $) | nindent 12 }}
370 {{- end }}
371 {{- if .Values.metrics.enabled }}
372 - name: metrics
373 image: {{ template "mongodb.metrics.image" . }}
374 imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
375 {{- if .Values.containerSecurityContext.enabled }}
376 securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) | nindent 12 }}
377 {{- end }}
378 {{- if .Values.diagnosticMode.enabled }}
379 command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
380 {{- else if .Values.metrics.command }}
381 command: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.command "context" $) | nindent 12 }}
382 {{- else }}
383 command:
384 - /bin/bash
385 - -ec
386 {{- end }}
387 {{- if .Values.diagnosticMode.enabled }}
388 args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
389 {{- else if .Values.metrics.args }}
390 args: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.args "context" $) | nindent 12 }}
391 {{- else }}
392 args:
393 - |
394 /bin/mongodb_exporter {{ include "mongodb.exporterArgs" $ }} --mongodb.direct-connect --mongodb.global-conn-pool --mongodb.uri "{{ include "mongodb.mongodb_exporter.uri" . }}" {{ .Values.metrics.extraFlags }}
395 {{- end }}
396 env:
397 {{- if .Values.auth.enabled }}
398 {{- if not .Values.metrics.username }}
399 - name: MONGODB_ROOT_USER
400 value: {{ .Values.auth.rootUser | quote }}
401 - name: MONGODB_ROOT_PASSWORD
402 valueFrom:
403 secretKeyRef:
404 name: {{ include "mongodb.secretName" . }}
405 key: mongodb-root-password
406 {{- else }}
407 - name: MONGODB_METRICS_USERNAME
408 value: {{ .Values.metrics.username | quote }}
409 - name: MONGODB_METRICS_PASSWORD
410 valueFrom:
411 secretKeyRef:
412 name: {{ include "mongodb.secretName" . }}
413 key: mongodb-metrics-password
414 {{- end }}
415 {{- end }}
416 volumeMounts:
417 - name: empty-dir
418 mountPath: /tmp
419 subPath: tmp-dir
420 {{- if .Values.tls.enabled }}
421 - name: certs
422 mountPath: /certs
423 {{- end }}
424 - name: empty-dir
425 mountPath: /opt/bitnami/redis-cluster/tmp
426 subPath: app-tmp-dir
427 {{- if .Values.metrics.extraVolumeMounts }}
428 {{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraVolumeMounts "context" $) | nindent 12 }}
429 {{- end }}
430 ports:
431 - name: metrics
432 containerPort: 9216
433 {{- if not .Values.diagnosticMode.enabled }}
434 {{- if .Values.metrics.customLivenessProbe }}
435 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
436 {{- else if .Values.metrics.livenessProbe.enabled }}
437 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
438 tcpSocket:
439 port: metrics
440 {{- end }}
441 {{- if .Values.metrics.customReadinessProbe }}
442 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
443 {{- else if .Values.metrics.readinessProbe.enabled }}
444 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
445 httpGet:
446 path: /
447 port: metrics
448 {{- end }}
449 {{- if .Values.metrics.customStartupProbe }}
450 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
451 {{- else if .Values.metrics.startupProbe.enabled }}
452 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
453 tcpSocket:
454 port: metrics
455 {{- end }}
456 {{- end }}
457 {{- if .Values.metrics.resources }}
458 resources: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.resources "context" $) | nindent 12 }}
459 {{- else if ne .Values.metrics.resourcesPreset "none" }}
460 resources: {{- include "common.resources.preset" (dict "type" .Values.metrics.resourcesPreset) | nindent 12 }}
461 {{- end }}
462 {{- end }}
463 {{- if .Values.hidden.sidecars }}
464 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.sidecars "context" $) | nindent 8 }}
465 {{- end }}
466 volumes:
467 - name: empty-dir
468 emptyDir: {}
469 - name: common-scripts
470 configMap:
471 name: {{ printf "%s-common-scripts" (include "mongodb.fullname" .) }}
472 defaultMode: 0555
473 {{- if or .Values.initdbScriptsConfigMap .Values.initdbScripts }}
474 - name: custom-init-scripts
475 configMap:
476 name: {{ template "mongodb.initdbScriptsCM" . }}
477 {{- end }}
478 {{- if or .Values.hidden.configuration .Values.hidden.existingConfigmap }}
479 - name: config
480 configMap:
481 name: {{ include "mongodb.hidden.configmapName" . }}
482 {{- end }}
483 {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }}
484 - name: shared
485 emptyDir: {}
486 {{- end }}
487 - name: scripts
488 configMap:
489 name: {{ printf "%s-scripts" (include "mongodb.fullname" .) }}
490 defaultMode: 0755
491 {{- if .Values.hidden.extraVolumes }}
492 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.extraVolumes "context" $) | nindent 8 }}
493 {{- end }}
494 {{- if .Values.tls.enabled }}
495 - name: certs
496 emptyDir: {}
497 {{- if (include "mongodb.autoGenerateCerts" .) }}
498 - name: certs-volume
499 secret:
500 secretName: {{ template "mongodb.tlsSecretName" . }}
501 items:
502 - key: mongodb-ca-cert
503 path: mongodb-ca-cert
504 mode: 0600
505 - key: mongodb-ca-key
506 path: mongodb-ca-key
507 mode: 0600
508 {{- else }}
509 {{- range $index, $secret := .Values.tls.hidden.existingSecrets }}
510 - name: mongodb-certs-{{ $index }}
511 secret:
512 secretName: {{ include "common.tplvalues.render" ( dict "value" $secret "context" $) }}
513 defaultMode: 256
514 {{- end }}
515 {{- end }}
516 {{- end }}
517 {{- if not .Values.hidden.persistence.enabled }}
518 - name: datadir
519 {{- if .Values.hidden.persistence.medium }}
520 emptyDir:
521 medium: {{ .Values.hidden.persistence.medium | quote }}
522 {{- else }}
523 emptyDir: {}
524 {{- end }}
525 {{- else }}
526 volumeClaimTemplates:
527 - metadata:
528 name: datadir
529 {{- if .Values.hidden.persistence.annotations }}
530 annotations: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.annotations "context" $) | nindent 10 }}
531 {{- end }}
532 {{- if .Values.persistence.labels }}
533 labels: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.labels "context" $) | nindent 10 }}
534 {{- end }}
535 spec:
536 accessModes:
537 {{- range .Values.hidden.persistence.accessModes }}
538 - {{ . | quote }}
539 {{- end }}
540 resources:
541 requests:
542 storage: {{ .Values.hidden.persistence.size | quote }}
543 {{- if .Values.hidden.persistence.volumeClaimTemplates.requests }}
544 {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.volumeClaimTemplates.requests "context" $) | nindent 12 }}
545 {{- end }}
546 {{- if .Values.hidden.persistence.volumeClaimTemplates.dataSource }}
547 dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.volumeClaimTemplates.dataSource "context" $) | nindent 10 }}
548 {{- end }}
549 {{- if .Values.hidden.persistence.volumeClaimTemplates.selector }}
550 selector: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.volumeClaimTemplates.selector "context" $) | nindent 10 }}
551 {{- end }}
552 {{ include "common.storage.class" (dict "persistence" .Values.hidden.persistence "global" .Values.global) }}
553 {{- end }}
554{{- end }}
555{{- end }}