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