Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 1 | {{- /* |
| 2 | Copyright VMware, Inc. |
| 3 | SPDX-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")) }} |
| 10 | apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} |
| 11 | kind: StatefulSet |
| 12 | metadata: |
| 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 }} |
| 22 | spec: |
| 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: {{- omit .Values.hidden.podSecurityContext "enabled" | toYaml | nindent 8 }} |
| 81 | {{- end }} |
| 82 | {{ if .Values.hidden.terminationGracePeriodSeconds }} |
| 83 | terminationGracePeriodSeconds: {{ .Values.hidden.terminationGracePeriodSeconds }} |
| 84 | {{- end }} |
| 85 | enableServiceLinks: {{ .Values.enableServiceLinks }} |
| 86 | {{- if or .Values.hidden.initContainers (and .Values.volumePermissions.enabled .Values.hidden.persistence.enabled) (and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled) .Values.tls.enabled }} |
| 87 | initContainers: |
| 88 | {{- if .Values.hidden.initContainers }} |
| 89 | {{- include "common.tplvalues.render" (dict "value" .Values.hidden.initContainers "context" $) | nindent 8 }} |
| 90 | {{- end }} |
| 91 | {{- if and .Values.volumePermissions.enabled .Values.hidden.persistence.enabled }} |
| 92 | - name: volume-permissions |
| 93 | image: {{ include "mongodb.volumePermissions.image" . }} |
| 94 | imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }} |
| 95 | command: |
| 96 | - /bin/bash |
| 97 | args: |
| 98 | - -ec |
| 99 | - | |
| 100 | mkdir -p {{ printf "%s/%s" .Values.hidden.persistence.mountPath (default "" .Values.hidden.persistence.subPath) }} |
| 101 | chown {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} {{ printf "%s/%s" .Values.hidden.persistence.mountPath (default "" .Values.hidden.persistence.subPath) }} |
| 102 | find {{ printf "%s/%s" .Values.hidden.persistence.mountPath (default "" .Values.hidden.persistence.subPath) }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} |
| 103 | {{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }} |
| 104 | securityContext: {{- omit .Values.volumePermissions.securityContext "runAsUser" | toYaml | nindent 12 }} |
| 105 | {{- else }} |
| 106 | securityContext: {{- .Values.volumePermissions.securityContext | toYaml | nindent 12 }} |
| 107 | {{- end }} |
| 108 | {{- if .Values.volumePermissions.resources }} |
| 109 | resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }} |
| 110 | {{- else if ne .Values.volumePermissions.resourcesPreset "none" }} |
| 111 | resources: {{- include "common.resources.preset" (dict "type" .Values.volumePermissions.resourcesPreset) | nindent 12 }} |
| 112 | {{- end }} |
| 113 | volumeMounts: |
| 114 | - name: empty-dir |
| 115 | mountPath: /tmp |
| 116 | subPath: tmp-dir |
| 117 | - name: datadir |
| 118 | mountPath: {{ .Values.hidden.persistence.mountPath }} |
| 119 | {{- end }} |
| 120 | {{- if .Values.tls.enabled }} |
| 121 | - name: generate-tls-certs |
| 122 | image: {{ include "mongodb.tls.image" . }} |
| 123 | imagePullPolicy: {{ .Values.tls.image.pullPolicy | quote }} |
| 124 | env: |
| 125 | - name: MY_POD_NAMESPACE |
| 126 | valueFrom: |
| 127 | fieldRef: |
| 128 | fieldPath: metadata.namespace |
| 129 | - name: MY_POD_HOST_IP |
| 130 | valueFrom: |
| 131 | fieldRef: |
| 132 | fieldPath: status.hostIP |
| 133 | - name: MY_POD_NAME |
| 134 | valueFrom: |
| 135 | fieldRef: |
| 136 | fieldPath: metadata.name |
| 137 | volumeMounts: |
| 138 | {{- if (include "mongodb.autoGenerateCerts" .) }} |
| 139 | - name: certs-volume |
| 140 | mountPath: /certs/CAs |
| 141 | {{- else }} |
| 142 | {{- range $index, $_ := .Values.tls.hidden.existingSecrets }} |
| 143 | - name: mongodb-certs-{{ $index }} |
| 144 | mountPath: /certs-{{ $index }} |
| 145 | {{- end }} |
| 146 | {{- end }} |
| 147 | - name: certs |
| 148 | mountPath: /certs |
| 149 | - name: common-scripts |
| 150 | mountPath: /bitnami/scripts |
| 151 | - name: empty-dir |
| 152 | mountPath: /tmp |
| 153 | subPath: tmp-dir |
| 154 | command: |
| 155 | - /bitnami/scripts/generate-certs.sh |
| 156 | args: |
| 157 | - -s {{ printf "%s-hidden-headless" (include "mongodb.fullname" .) }} |
| 158 | {{- if .Values.externalAccess.hidden.service.loadBalancerIPs }} |
| 159 | - -i {{ join "," .Values.externalAccess.hidden.service.loadBalancerIPs }} |
| 160 | {{- end }} |
| 161 | {{- if .Values.tls.extraDnsNames }} |
| 162 | - -n {{ join "," .Values.tls.extraDnsNames }} |
| 163 | {{- end }} |
| 164 | {{- if .Values.tls.resources }} |
| 165 | resources: {{- toYaml .Values.tls.resources | nindent 12 }} |
| 166 | {{- else if ne .Values.tls.resourcesPreset "none" }} |
| 167 | resources: {{- include "common.resources.preset" (dict "type" .Values.tls.resourcesPreset) | nindent 12 }} |
| 168 | {{- end }} |
| 169 | {{- end }} |
| 170 | {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }} |
| 171 | - name: auto-discovery |
| 172 | image: {{ include "mongodb.externalAccess.autoDiscovery.image" . }} |
| 173 | imagePullPolicy: {{ .Values.externalAccess.autoDiscovery.image.pullPolicy | quote }} |
| 174 | command: |
| 175 | - /scripts/auto-discovery.sh |
| 176 | # We need the service account token for contacting the k8s API |
| 177 | automountServiceAccountToken: true |
| 178 | env: |
| 179 | - name: MY_POD_NAME |
| 180 | valueFrom: |
| 181 | fieldRef: |
| 182 | fieldPath: metadata.name |
| 183 | - name: SHARED_FILE |
| 184 | value: "/shared/info.txt" |
| 185 | {{- if .Values.externalAccess.autoDiscovery.resources }} |
| 186 | resources: {{- toYaml .Values.externalAccess.autoDiscovery.resources | nindent 12 }} |
| 187 | {{- else if ne .Values.externalAccess.autoDiscovery.resourcesPreset "none" }} |
| 188 | resources: {{- include "common.resources.preset" (dict "type" .Values.externalAccess.autoDiscovery.resourcesPreset) | nindent 12 }} |
| 189 | {{- end }} |
| 190 | volumeMounts: |
| 191 | - name: shared |
| 192 | mountPath: /shared |
| 193 | - name: scripts |
| 194 | mountPath: /scripts/auto-discovery.sh |
| 195 | subPath: auto-discovery.sh |
| 196 | - name: empty-dir |
| 197 | mountPath: /tmp |
| 198 | subPath: tmp-dir |
| 199 | {{- end }} |
| 200 | {{- end }} |
| 201 | containers: |
| 202 | - name: mongodb |
| 203 | image: {{ include "mongodb.image" . }} |
| 204 | imagePullPolicy: {{ .Values.image.pullPolicy | quote }} |
| 205 | {{- if .Values.hidden.containerSecurityContext.enabled }} |
| 206 | securityContext: {{- omit .Values.hidden.containerSecurityContext "enabled" | toYaml | nindent 12 }} |
| 207 | {{- end }} |
| 208 | {{- if .Values.diagnosticMode.enabled }} |
| 209 | command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} |
| 210 | {{- else if .Values.hidden.command }} |
| 211 | command: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.command "context" $) | nindent 12 }} |
| 212 | {{- else }} |
| 213 | command: |
| 214 | - /scripts/setup-hidden.sh |
| 215 | {{- end }} |
| 216 | {{- if .Values.diagnosticMode.enabled }} |
| 217 | args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} |
| 218 | {{- else if .Values.hidden.args }} |
| 219 | args: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.args "context" $) | nindent 12 }} |
| 220 | {{- end }} |
| 221 | {{- if .Values.hidden.lifecycleHooks }} |
| 222 | lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.lifecycleHooks "context" $) | nindent 12 }} |
| 223 | {{- end }} |
| 224 | env: |
| 225 | - name: BITNAMI_DEBUG |
| 226 | value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }} |
| 227 | {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }} |
| 228 | - name: SHARED_FILE |
| 229 | value: "/shared/info.txt" |
| 230 | {{- end }} |
| 231 | - name: MY_POD_NAME |
| 232 | valueFrom: |
| 233 | fieldRef: |
| 234 | fieldPath: metadata.name |
| 235 | - name: MY_POD_HOST_IP |
| 236 | valueFrom: |
| 237 | fieldRef: |
| 238 | fieldPath: status.hostIP |
| 239 | - name: MY_POD_NAMESPACE |
| 240 | valueFrom: |
| 241 | fieldRef: |
| 242 | fieldPath: metadata.namespace |
| 243 | - name: K8S_SERVICE_NAME |
| 244 | value: "{{ include "mongodb.service.nameOverride" . }}" |
| 245 | - name: K8S_HIDDEN_NODE_SERVICE_NAME |
| 246 | value: "{{ include "mongodb.fullname" . }}-hidden-headless" |
| 247 | - name: MONGODB_REPLICA_SET_MODE |
| 248 | value: "hidden" |
| 249 | - name: MONGODB_INITIAL_PRIMARY_HOST |
| 250 | value: {{ printf "%s-0.$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.%s" (include "mongodb.fullname" .) .Values.clusterDomain }} |
| 251 | - name: MONGODB_REPLICA_SET_NAME |
| 252 | value: {{ .Values.replicaSetName | quote }} |
| 253 | {{- if and .Values.replicaSetHostnames (not .Values.externalAccess.hidden.enabled) }} |
| 254 | - name: MONGODB_ADVERTISED_HOSTNAME |
| 255 | value: "$(MY_POD_NAME).$(K8S_HIDDEN_NODE_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.{{ .Values.clusterDomain }}" |
| 256 | {{- end }} |
| 257 | {{- $customUsers := include "mongodb.customUsers" . -}} |
| 258 | {{- $customDatabases := include "mongodb.customDatabases" . -}} |
| 259 | {{- if not (empty $customUsers) }} |
| 260 | - name: MONGODB_EXTRA_USERNAMES |
| 261 | value: {{ $customUsers | quote }} |
| 262 | {{- end }} |
| 263 | {{- if not (empty $customDatabases) }} |
| 264 | - name: MONGODB_EXTRA_DATABASES |
| 265 | value: {{ $customDatabases | quote }} |
| 266 | {{- end }} |
| 267 | {{- if .Values.auth.enabled }} |
| 268 | {{- if and (not (empty $customUsers)) (not (empty $customDatabases)) }} |
| 269 | - name: MONGODB_EXTRA_PASSWORDS |
| 270 | valueFrom: |
| 271 | secretKeyRef: |
| 272 | name: {{ include "mongodb.secretName" . }} |
| 273 | key: mongodb-passwords |
| 274 | {{- end }} |
| 275 | - name: MONGODB_ROOT_USER |
| 276 | value: {{ .Values.auth.rootUser | quote }} |
| 277 | - name: MONGODB_ROOT_PASSWORD |
| 278 | valueFrom: |
| 279 | secretKeyRef: |
| 280 | name: {{ include "mongodb.secretName" . }} |
| 281 | key: mongodb-root-password |
| 282 | - name: MONGODB_REPLICA_SET_KEY |
| 283 | valueFrom: |
| 284 | secretKeyRef: |
| 285 | name: {{ include "mongodb.secretName" . }} |
| 286 | key: mongodb-replica-set-key |
| 287 | {{- end }} |
| 288 | {{- if and .Values.metrics.enabled (not (empty .Values.metrics.username)) }} |
| 289 | - name: MONGODB_METRICS_USERNAME |
| 290 | value: {{ .Values.metrics.username | quote }} |
| 291 | {{- if .Values.auth.enabled }} |
| 292 | - name: MONGODB_METRICS_PASSWORD |
| 293 | valueFrom: |
| 294 | secretKeyRef: |
| 295 | name: {{ include "mongodb.secretName" . }} |
| 296 | key: mongodb-metrics-password |
| 297 | {{- end }} |
| 298 | {{- end }} |
| 299 | - name: ALLOW_EMPTY_PASSWORD |
| 300 | value: {{ ternary "no" "yes" .Values.auth.enabled | quote }} |
| 301 | - name: MONGODB_SYSTEM_LOG_VERBOSITY |
| 302 | value: {{ .Values.systemLogVerbosity | quote }} |
| 303 | - name: MONGODB_DISABLE_SYSTEM_LOG |
| 304 | value: {{ ternary "yes" "no" .Values.disableSystemLog | quote }} |
| 305 | - name: MONGODB_DISABLE_JAVASCRIPT |
| 306 | value: {{ ternary "yes" "no" .Values.disableJavascript | quote }} |
| 307 | - name: MONGODB_ENABLE_JOURNAL |
| 308 | value: {{ ternary "yes" "no" .Values.enableJournal | quote }} |
| 309 | - name: MONGODB_PORT_NUMBER |
| 310 | value: {{ .Values.hidden.containerPorts.mongodb | quote }} |
| 311 | - name: MONGODB_ENABLE_IPV6 |
| 312 | value: {{ ternary "yes" "no" .Values.enableIPv6 | quote }} |
| 313 | - name: MONGODB_ENABLE_DIRECTORY_PER_DB |
| 314 | value: {{ ternary "yes" "no" .Values.directoryPerDB | quote }} |
| 315 | {{- $extraFlags := .Values.hidden.extraFlags | join " " -}} |
| 316 | {{- if .Values.tls.enabled }} |
| 317 | {{- if .Values.tls.mTLS.enabled }} |
| 318 | {{- $extraFlags = printf "--tlsCAFile=/certs/mongodb-ca-cert %s" $extraFlags }} |
| 319 | {{- end }} |
| 320 | {{- $extraFlags = printf "--tlsMode=%s --tlsCertificateKeyFile=/certs/mongodb.pem %s" .Values.tls.mode $extraFlags }} |
| 321 | {{- end }} |
| 322 | {{- if ne $extraFlags "" }} |
| 323 | - name: MONGODB_EXTRA_FLAGS |
| 324 | value: {{ $extraFlags | quote }} |
| 325 | {{- end }} |
| 326 | {{- if .Values.tls.enabled }} |
| 327 | - name: MONGODB_CLIENT_EXTRA_FLAGS |
| 328 | value: --tls {{ if .Values.tls.mTLS.enabled }}--tlsCertificateKeyFile=/certs/mongodb.pem {{ end }}--tlsCAFile=/certs/mongodb-ca-cert |
| 329 | {{- end }} |
| 330 | {{- if .Values.hidden.extraEnvVars }} |
| 331 | {{- include "common.tplvalues.render" (dict "value" .Values.hidden.extraEnvVars "context" $) | nindent 12 }} |
| 332 | {{- end }} |
| 333 | {{- if or .Values.hidden.extraEnvVarsCM .Values.hidden.extraEnvVarsSecret }} |
| 334 | envFrom: |
| 335 | {{- if .Values.hidden.extraEnvVarsCM }} |
| 336 | - configMapRef: |
| 337 | name: {{ tpl .Values.hidden.extraEnvVarsCM . | quote }} |
| 338 | {{- end }} |
| 339 | {{- if .Values.hidden.extraEnvVarsSecret }} |
| 340 | - secretRef: |
| 341 | name: {{ tpl .Values.hidden.extraEnvVarsSecret . | quote }} |
| 342 | {{- end }} |
| 343 | {{- end }} |
| 344 | ports: |
| 345 | - containerPort: {{ .Values.hidden.containerPorts.mongodb }} |
| 346 | name: mongodb |
| 347 | {{- if not .Values.diagnosticMode.enabled }} |
| 348 | {{- if .Values.hidden.customLivenessProbe }} |
| 349 | livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.customLivenessProbe "context" $) | nindent 12 }} |
| 350 | {{- else if .Values.hidden.livenessProbe.enabled }} |
| 351 | livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.hidden.livenessProbe "enabled") "context" $) | nindent 12 }} |
| 352 | exec: |
| 353 | command: |
| 354 | - /bitnami/scripts/ping-mongodb.sh |
| 355 | {{- end }} |
| 356 | {{- if .Values.hidden.customReadinessProbe }} |
| 357 | readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.customReadinessProbe "context" $) | nindent 12 }} |
| 358 | {{- else if .Values.hidden.readinessProbe.enabled }} |
| 359 | readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.hidden.readinessProbe "enabled") "context" $) | nindent 12 }} |
| 360 | exec: |
| 361 | command: |
| 362 | - /bitnami/scripts/ping-mongodb.sh |
| 363 | {{- end }} |
| 364 | {{- if .Values.hidden.customStartupProbe }} |
| 365 | startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.customStartupProbe "context" $) | nindent 12 }} |
| 366 | {{- else if .Values.hidden.startupProbe.enabled }} |
| 367 | startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.hidden.startupProbe "enabled") "context" $) | nindent 12 }} |
| 368 | exec: |
| 369 | command: |
| 370 | - /bitnami/scripts/startup-probe.sh |
| 371 | {{- end }} |
| 372 | {{- end }} |
| 373 | {{- if .Values.hidden.resources }} |
| 374 | resources: {{- toYaml .Values.hidden.resources | nindent 12 }} |
| 375 | {{- else if ne .Values.hidden.resourcesPreset "none" }} |
| 376 | resources: {{- include "common.resources.preset" (dict "type" .Values.hidden.resourcesPreset) | nindent 12 }} |
| 377 | {{- end }} |
| 378 | volumeMounts: |
| 379 | - name: datadir |
| 380 | mountPath: {{ .Values.hidden.persistence.mountPath }} |
| 381 | subPath: {{ .Values.hidden.persistence.subPath }} |
| 382 | - name: common-scripts |
| 383 | mountPath: /bitnami/scripts |
| 384 | {{- if or .Values.initdbScriptsConfigMap .Values.initdbScripts }} |
| 385 | - name: custom-init-scripts |
| 386 | mountPath: /docker-entrypoint-initdb.d |
| 387 | {{- end }} |
| 388 | {{- if or .Values.hidden.configuration .Values.hidden.existingConfigmap }} |
| 389 | - name: config |
| 390 | mountPath: /opt/bitnami/mongodb/conf/mongodb.conf |
| 391 | subPath: mongodb.conf |
| 392 | {{- end }} |
| 393 | - name: scripts |
| 394 | mountPath: /scripts/setup-hidden.sh |
| 395 | subPath: setup-hidden.sh |
| 396 | {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }} |
| 397 | - name: shared |
| 398 | mountPath: /shared |
| 399 | {{- end }} |
| 400 | {{- if .Values.tls.enabled }} |
| 401 | - name: certs |
| 402 | mountPath: /certs |
| 403 | {{- end }} |
| 404 | - name: empty-dir |
| 405 | mountPath: /tmp |
| 406 | subPath: tmp-dir |
| 407 | - name: empty-dir |
| 408 | mountPath: /opt/bitnami/mongodb/conf |
| 409 | subPath: app-conf-dir |
| 410 | - name: empty-dir |
| 411 | mountPath: /opt/bitnami/mongodb/tmp |
| 412 | subPath: app-tmp-dir |
| 413 | - name: empty-dir |
| 414 | mountPath: /opt/bitnami/mongodb/logs |
| 415 | subPath: app-logs-dir |
| 416 | {{- if .Values.hidden.extraVolumeMounts }} |
| 417 | {{- include "common.tplvalues.render" (dict "value" .Values.hidden.extraVolumeMounts "context" $) | nindent 12 }} |
| 418 | {{- end }} |
| 419 | {{- if .Values.metrics.enabled }} |
| 420 | - name: metrics |
| 421 | image: {{ template "mongodb.metrics.image" . }} |
| 422 | imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} |
| 423 | {{- if .Values.containerSecurityContext.enabled }} |
| 424 | securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }} |
| 425 | {{- end }} |
| 426 | {{- if .Values.diagnosticMode.enabled }} |
| 427 | command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }} |
| 428 | {{- else if .Values.metrics.command }} |
| 429 | command: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.command "context" $) | nindent 12 }} |
| 430 | {{- else }} |
| 431 | command: |
| 432 | - /bin/bash |
| 433 | - -ec |
| 434 | {{- end }} |
| 435 | {{- if .Values.diagnosticMode.enabled }} |
| 436 | args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }} |
| 437 | {{- else if .Values.metrics.args }} |
| 438 | args: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.args "context" $) | nindent 12 }} |
| 439 | {{- else }} |
| 440 | args: |
| 441 | - | |
| 442 | /bin/mongodb_exporter {{ include "mongodb.exporterArgs" $ }} --mongodb.direct-connect --mongodb.global-conn-pool --mongodb.uri "{{ include "mongodb.mongodb_exporter.uri" . }}" {{ .Values.metrics.extraFlags }} |
| 443 | {{- end }} |
| 444 | env: |
| 445 | {{- if .Values.auth.enabled }} |
| 446 | {{- if not .Values.metrics.username }} |
| 447 | - name: MONGODB_ROOT_USER |
| 448 | value: {{ .Values.auth.rootUser | quote }} |
| 449 | - name: MONGODB_ROOT_PASSWORD |
| 450 | valueFrom: |
| 451 | secretKeyRef: |
| 452 | name: {{ include "mongodb.secretName" . }} |
| 453 | key: mongodb-root-password |
| 454 | {{- else }} |
| 455 | - name: MONGODB_METRICS_USERNAME |
| 456 | value: {{ .Values.metrics.username | quote }} |
| 457 | - name: MONGODB_METRICS_PASSWORD |
| 458 | valueFrom: |
| 459 | secretKeyRef: |
| 460 | name: {{ include "mongodb.secretName" . }} |
| 461 | key: mongodb-metrics-password |
| 462 | {{- end }} |
| 463 | {{- end }} |
| 464 | volumeMounts: |
| 465 | - name: empty-dir |
| 466 | mountPath: /tmp |
| 467 | subPath: tmp-dir |
| 468 | {{- if .Values.tls.enabled }} |
| 469 | - name: certs |
| 470 | mountPath: /certs |
| 471 | {{- end }} |
| 472 | - name: empty-dir |
| 473 | mountPath: /opt/bitnami/redis-cluster/tmp |
| 474 | subPath: app-tmp-dir |
| 475 | {{- if .Values.metrics.extraVolumeMounts }} |
| 476 | {{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraVolumeMounts "context" $) | nindent 12 }} |
| 477 | {{- end }} |
| 478 | ports: |
| 479 | - name: metrics |
| 480 | containerPort: 9216 |
| 481 | {{- if not .Values.diagnosticMode.enabled }} |
| 482 | {{- if .Values.metrics.customLivenessProbe }} |
| 483 | livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }} |
| 484 | {{- else if .Values.metrics.livenessProbe.enabled }} |
| 485 | livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }} |
| 486 | httpGet: |
| 487 | path: / |
| 488 | port: metrics |
| 489 | {{- end }} |
| 490 | {{- if .Values.metrics.customReadinessProbe }} |
| 491 | readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }} |
| 492 | {{- else if .Values.metrics.readinessProbe.enabled }} |
| 493 | readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }} |
| 494 | httpGet: |
| 495 | path: / |
| 496 | port: metrics |
| 497 | {{- end }} |
| 498 | {{- if .Values.metrics.customStartupProbe }} |
| 499 | startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }} |
| 500 | {{- else if .Values.metrics.startupProbe.enabled }} |
| 501 | startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }} |
| 502 | tcpSocket: |
| 503 | port: metrics |
| 504 | {{- end }} |
| 505 | {{- end }} |
| 506 | {{- if .Values.metrics.resources }} |
| 507 | resources: {{- toYaml .Values.metrics.resources | nindent 12 }} |
| 508 | {{- else if ne .Values.metrics.resourcesPreset "none" }} |
| 509 | resources: {{- include "common.resources.preset" (dict "type" .Values.metrics.resourcesPreset) | nindent 12 }} |
| 510 | {{- end }} |
| 511 | {{- end }} |
| 512 | {{- if .Values.hidden.sidecars }} |
| 513 | {{- include "common.tplvalues.render" (dict "value" .Values.hidden.sidecars "context" $) | nindent 8 }} |
| 514 | {{- end }} |
| 515 | volumes: |
| 516 | - name: empty-dir |
Fiete Ostkamp | d2b2a3d | 2024-04-30 13:08:03 +0200 | [diff] [blame^] | 517 | emptyDir: |
| 518 | sizeLimit: 64Mi |
Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 519 | - name: common-scripts |
| 520 | configMap: |
| 521 | name: {{ printf "%s-common-scripts" (include "mongodb.fullname" .) }} |
| 522 | defaultMode: 0555 |
| 523 | {{- if or .Values.initdbScriptsConfigMap .Values.initdbScripts }} |
| 524 | - name: custom-init-scripts |
| 525 | configMap: |
| 526 | name: {{ template "mongodb.initdbScriptsCM" . }} |
| 527 | {{- end }} |
| 528 | {{- if or .Values.hidden.configuration .Values.hidden.existingConfigmap }} |
| 529 | - name: config |
| 530 | configMap: |
| 531 | name: {{ include "mongodb.hidden.configmapName" . }} |
| 532 | {{- end }} |
| 533 | {{- if and .Values.externalAccess.hidden.enabled .Values.externalAccess.autoDiscovery.enabled (eq .Values.externalAccess.hidden.service.type "LoadBalancer") }} |
| 534 | - name: shared |
Fiete Ostkamp | d2b2a3d | 2024-04-30 13:08:03 +0200 | [diff] [blame^] | 535 | emptyDir: |
| 536 | sizeLimit: 64Mi |
Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 537 | {{- end }} |
| 538 | - name: scripts |
| 539 | configMap: |
| 540 | name: {{ printf "%s-scripts" (include "mongodb.fullname" .) }} |
| 541 | defaultMode: 0755 |
| 542 | {{- if .Values.hidden.extraVolumes }} |
| 543 | {{- include "common.tplvalues.render" (dict "value" .Values.hidden.extraVolumes "context" $) | nindent 8 }} |
| 544 | {{- end }} |
| 545 | {{- if .Values.tls.enabled }} |
| 546 | - name: certs |
Fiete Ostkamp | d2b2a3d | 2024-04-30 13:08:03 +0200 | [diff] [blame^] | 547 | emptyDir: |
| 548 | sizeLimit: 64Mi |
Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 549 | {{- if (include "mongodb.autoGenerateCerts" .) }} |
| 550 | - name: certs-volume |
| 551 | secret: |
| 552 | secretName: {{ template "mongodb.tlsSecretName" . }} |
| 553 | items: |
| 554 | - key: mongodb-ca-cert |
| 555 | path: mongodb-ca-cert |
| 556 | mode: 0600 |
| 557 | - key: mongodb-ca-key |
| 558 | path: mongodb-ca-key |
| 559 | mode: 0600 |
| 560 | {{- else }} |
| 561 | {{- range $index, $secret := .Values.tls.hidden.existingSecrets }} |
| 562 | - name: mongodb-certs-{{ $index }} |
| 563 | secret: |
| 564 | secretName: {{ include "common.tplvalues.render" ( dict "value" $secret "context" $) }} |
| 565 | defaultMode: 256 |
| 566 | {{- end }} |
| 567 | {{- end }} |
| 568 | {{- end }} |
| 569 | {{- if not .Values.hidden.persistence.enabled }} |
| 570 | - name: datadir |
| 571 | {{- if .Values.hidden.persistence.medium }} |
| 572 | emptyDir: |
| 573 | medium: {{ .Values.hidden.persistence.medium | quote }} |
Fiete Ostkamp | d2b2a3d | 2024-04-30 13:08:03 +0200 | [diff] [blame^] | 574 | sizeLimit: 64Mi |
Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 575 | {{- else }} |
Fiete Ostkamp | d2b2a3d | 2024-04-30 13:08:03 +0200 | [diff] [blame^] | 576 | emptyDir: |
| 577 | sizeLimit: 64Mi |
Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 578 | {{- end }} |
| 579 | {{- else }} |
| 580 | volumeClaimTemplates: |
| 581 | - metadata: |
| 582 | name: datadir |
| 583 | {{- if .Values.hidden.persistence.annotations }} |
| 584 | annotations: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.annotations "context" $) | nindent 10 }} |
| 585 | {{- end }} |
| 586 | spec: |
| 587 | accessModes: |
| 588 | {{- range .Values.hidden.persistence.accessModes }} |
| 589 | - {{ . | quote }} |
| 590 | {{- end }} |
| 591 | resources: |
| 592 | requests: |
| 593 | storage: {{ .Values.hidden.persistence.size | quote }} |
| 594 | {{- if .Values.hidden.persistence.volumeClaimTemplates.requests }} |
| 595 | {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.volumeClaimTemplates.requests "context" $) | nindent 12 }} |
| 596 | {{- end }} |
| 597 | {{- if .Values.hidden.persistence.volumeClaimTemplates.dataSource }} |
| 598 | dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.volumeClaimTemplates.dataSource "context" $) | nindent 10 }} |
| 599 | {{- end }} |
| 600 | {{- if .Values.hidden.persistence.volumeClaimTemplates.selector }} |
| 601 | selector: {{- include "common.tplvalues.render" (dict "value" .Values.hidden.persistence.volumeClaimTemplates.selector "context" $) | nindent 10 }} |
| 602 | {{- end }} |
| 603 | {{ include "common.storage.class" (dict "persistence" .Values.hidden.persistence "global" .Values.global) }} |
| 604 | {{- end }} |
| 605 | {{- end }} |
| 606 | {{- end }} |