Pridanie suborov

This commit is contained in:
IKO
2026-04-16 17:59:10 +02:00
parent 9d6d252b5f
commit 9936994d0d
62 changed files with 10272 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}
? WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
Subscribe to Bitnami Secure Images to receive continued support and security updates.
More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267
** Please be patient while the chart is being deployed **
{{- if .Values.diagnosticMode.enabled }}
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
Get the list of pods by executing:
kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }}
Access the pod you want to debug by executing
kubectl exec --namespace {{ .Release.Namespace }} -ti <NAME OF THE POD> -- bash
In order to replicate the container startup scripts execute this command:
/opt/bitnami/scripts/mongodb-sharded/entrypoint.sh /opt/bitnami/scripts/mongodb-sharded/run.sh
{{- else }}
The MongoDB&reg; Sharded cluster can be accessed via the Mongos instances in port {{ .Values.service.ports.mongodb }} on the following DNS name from within your cluster:
{{ include "mongodb-sharded.serviceName" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
To get the {{ .Values.auth.rootUser }} password run:
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath="{.data.mongodb-root-password}" | base64 -d)
To connect to your database run the following command:
kubectl run --namespace {{ .Release.Namespace }} {{ printf "%s-client" (include "common.names.fullname" .) }} --rm --tty -i --restart='Never' --image {{ template "mongodb-sharded.image" . }} --command -- mongosh admin --host {{ include "mongodb-sharded.serviceName" . }} {{- if .Values.auth.enabled }} --authenticationDatabase admin -u {{ .Values.auth.rootUser }} -p $MONGODB_ROOT_PASSWORD{{- end }}
To connect to your database from outside the cluster execute the following commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mongodb-sharded.serviceName" . }})
mongosh --host $NODE_IP --port $NODE_PORT --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ include "mongodb-sharded.serviceName" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mongodb-sharded.serviceName" . }} --include "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
mongosh --host $SERVICE_IP --port {{ .Values.service.ports.mongodb }} --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD
{{- else if contains "ClusterIP" .Values.service.type }}
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "mongodb-sharded.serviceName" . }} {{ .Values.service.ports.mongodb }}:{{ .Values.service.ports.mongodb }} &
mongosh --host 127.0.0.1 --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD
{{- end }}
{{- end }}
{{- include "mongodb-sharded.validateValues" . -}}
{{- include "mongodb-sharded.checkRollingTags" . -}}
{{- include "common.warnings.resources" (dict "sections" (list "configsvr" "metrics" "mongos" "shardsvr.arbiter" "shardsvr.dataNode" "volumePermissions") "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.image .Values.volumePermissions.image .Values.metrics.image) "context" $) }}
{{- include "common.errors.insecureImages" (dict "images" (list .Values.image .Values.volumePermissions.image .Values.metrics.image) "context" $) }}

View File

@@ -0,0 +1,323 @@
{{/*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{/* vim: set filetype=mustache: */}}
{{/*
Returns a ServiceAccount name for specified path or falls back to `common.serviceAccount.name`
if `common.serviceAccount.create` is set to true. Falls back to Chart's fullname otherwise.
Usage:
{{ include "mongodb-sharded.serviceAccountName" (dict "component" "mongos" "value" .Values.path.to.serviceAccount "context" $) }}
*/}}
{{- define "mongodb-sharded.serviceAccountName" -}}
{{- if .value.create }}
{{- default (printf "%s-%s" (include "common.names.fullname" .context) .component) .value.name | quote }}
{{- else if .context.Values.common.serviceAccount.create }}
{{- default (printf "%s-%s" (include "common.names.fullname" .context) .component) .context.Values.common.serviceAccount.name | quote }}
{{- else -}}
{{- default "default" .value.name | quote }}
{{- end }}
{{- end }}
{{- define "mongodb-sharded.secret" -}}
{{- if .Values.auth.existingSecret -}}
{{- printf "%s" (tpl .Values.auth.existingSecret $) -}}
{{- else }}
{{- include "common.names.fullname" . -}}
{{- end }}
{{- end -}}
{{- define "mongodb-sharded.configServer.primaryHost" -}}
{{- if .Values.configsvr.external.host -}}
{{- .Values.configsvr.external.host }}
{{- else -}}
{{- printf "%s-configsvr-0.%s-headless.%s.svc.%s" (include "common.names.fullname" . ) (include "common.names.fullname" .) (include "common.names.namespace" .) .Values.clusterDomain -}}
{{- end -}}
{{- end -}}
{{- define "mongodb-sharded.configServer.rsName" -}}
{{- if .Values.configsvr.external.replicasetName -}}
{{- .Values.configsvr.external.replicasetName }}
{{- else }}
{{- printf "%s-configsvr" ( include "common.names.fullname" . ) -}}
{{- end }}
{{- end -}}
{{- define "mongodb-sharded.mongos.configCM" -}}
{{- if .Values.mongos.configCM -}}
{{- .Values.mongos.configCM -}}
{{- else }}
{{- printf "%s-mongos" (include "common.names.fullname" .) -}}
{{- end }}
{{- end -}}
{{- define "mongodb-sharded.shardsvr.dataNode.configCM" -}}
{{- if .Values.shardsvr.dataNode.configCM -}}
{{- .Values.shardsvr.dataNode.configCM -}}
{{- else }}
{{- printf "%s-shardsvr-data" (include "common.names.fullname" .) -}}
{{- end }}
{{- end -}}
{{- define "mongodb-sharded.shardsvr.arbiter.configCM" -}}
{{- if .Values.shardsvr.arbiter.configCM -}}
{{- .Values.shardsvr.arbiter.configCM -}}
{{- else }}
{{- printf "%s-shardsvr-arbiter" (include "common.names.fullname" .) -}}
{{- end }}
{{- end -}}
{{- define "mongodb-sharded.configsvr.configCM" -}}
{{- if .Values.configsvr.configCM -}}
{{- .Values.configsvr.configCM -}}
{{- else }}
{{- printf "%s-configsvr" (include "common.names.fullname" .) -}}
{{- end }}
{{- end -}}
{{/*
Get the initialization scripts Secret name.
*/}}
{{- define "mongodb-sharded.initScriptsSecret" -}}
{{- printf "%s" (include "common.tplvalues.render" (dict "value" .Values.common.initScriptsSecret "context" $)) -}}
{{- end -}}
{{/*
Get the initialization scripts configmap name.
*/}}
{{- define "mongodb-sharded.initScriptsCM" -}}
{{- printf "%s" (include "common.tplvalues.render" (dict "value" .Values.common.initScriptsCM "context" $)) -}}
{{- end -}}
{{/*
Returns the proper Service name depending if an explicit service name is set
in the values file. If the name is not explicitly set it will take the "common.names.fullname"
*/}}
{{- define "mongodb-sharded.serviceName" -}}
{{- if .Values.service.name -}}
{{ .Values.service.name }}
{{- else -}}
{{ include "common.names.fullname" . }}
{{- end -}}
{{- end -}}
{{/*
Return the proper MongoDB&reg; image name
*/}}
{{- define "mongodb-sharded.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper image name (for the metrics image)
*/}}
{{- define "mongodb-sharded.metrics.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.metrics.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper image name (for the init container volume-permissions image)
*/}}
{{- define "mongodb-sharded.volumePermissions.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "mongodb-sharded.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.metrics.image .Values.volumePermissions.image) "global" .Values.global) -}}
{{- end -}}
{{/*
Compile all warnings into a single message, and call fail.
*/}}
{{- define "mongodb-sharded.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.externalCfgServer" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.replicaCount" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.clusterIPListLength" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.nodePortListLength" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.loadBalancerIPListLength" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.config" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}
{{/*
Validate values of MongoDB&reg; - If using an external config server, then both the host and the replicaset name should be set.
*/}}
{{- define "mongodb-sharded.validateValues.externalCfgServer" -}}
{{- if and .Values.configsvr.external.replicasetName (not .Values.configsvr.external.host) -}}
mongodb: invalidExternalConfigServer
You specified a replica set name for the external config server but not a host. Set both configsvr.external.replicasetName and configsvr.external.host
{{- end -}}
{{- if and (not .Values.configsvr.external.replicasetName) .Values.configsvr.external.host -}}
mongodb: invalidExternalConfigServer
You specified a host for the external config server but not the replica set name. Set both configsvr.external.replicasetName and configsvr.external.host
{{- end -}}
{{- if and .Values.configsvr.external.host (not .Values.configsvr.external.rootPassword) -}}
mongodb: invalidExternalConfigServer
You specified a host for the external config server but not the root password. Set the configsvr.external.rootPassword value.
{{- end -}}
{{- if and .Values.configsvr.external.host (not .Values.configsvr.external.replicasetKey) -}}
mongodb: invalidExternalConfigServer
You specified a host for the external config server but not the replica set key. Set the configsvr.external.replicasetKey value.
{{- end -}}
{{- end -}}
{{/*
Validate values of MongoDB&reg; - The number of shards must be positive, as well as the data node replicaCount
*/}}
{{- define "mongodb-sharded.validateValues.replicaCount" -}}
{{- if and (le (int .Values.shardsvr.dataNode.replicaCount) 0) (ge (int .Values.shards) 1) }}
mongodb: invalidShardSvrReplicas
You specified an invalid number of replicas per shard. Please set shardsvr.dataNode.replicaCount with a positive number or set the number of shards to 0.
{{- end -}}
{{- if lt (int .Values.shardsvr.arbiter.replicaCount) 0 }}
mongodb: invalidShardSvrArbiters
You specified an invalid number of arbiters per shard. Please set shardsvr.arbiter.replicaCount with a number greater or equal than 0
{{- end -}}
{{- if and (le (int .Values.configsvr.replicaCount) 0) (not .Values.configsvr.external.host) }}
mongodb: invalidConfigSvrReplicas
You specified an invalid number of replicas per shard. Please set configsvr.replicaCount with a positive number or set the configsvr.external.host value to use
an external config server replicaset
{{- end -}}
{{- end -}}
{{/*
Validate values of MongoDB&reg; - Cannot use both .config and .configCM
*/}}
{{- define "mongodb-sharded.validateValues.config" -}}
{{- if and .Values.shardsvr.dataNode.configCM .Values.shardsvr.dataNode.config }}
mongodb: shardDataNodeConflictingConfig
You specified both shardsvr.dataNode.configCM and shardsvr.dataNode.config. You can only set one
{{- end -}}
{{- if and .Values.shardsvr.arbiter.configCM .Values.shardsvr.arbiter.config }}
mongodb: arbiterNodeConflictingConfig
You specified both shardsvr.arbiter.configCM and shardsvr.arbiter.config. You can only set one
{{- end -}}
{{- if and .Values.mongos.configCM .Values.mongos.config }}
mongodb: mongosNodeConflictingConfig
You specified both mongos.configCM and mongos.config. You can only set one
{{- end -}}
{{- if and .Values.configsvr.configCM .Values.configsvr.config }}
mongodb: configSvrNodeConflictingConfig
You specified both configsvr.configCM and configsvr.config. You can only set one
{{- end -}}
{{- end -}}
{{/* Validate values of MongoDB&reg; - number of replicas must be the same as NodePort list */}}
{{- define "mongodb-sharded.validateValues.nodePortListLength" -}}
{{- $replicaCount := int .Values.mongos.replicaCount }}
{{- $nodePortListLength := len .Values.mongos.servicePerReplica.nodePorts }}
{{- if and .Values.mongos.useStatefulSet .Values.mongos.servicePerReplica.enabled (not (eq $replicaCount $nodePortListLength )) (eq .Values.mongos.servicePerReplica.type "NodePort") -}}
mongodb: .Values.mongos.servicePerReplica.nodePorts
Number of mongos.replicaCount and mongos.servicePerReplica.nodePorts array length must be the same. Currently: replicaCount = {{ $replicaCount }} and nodePorts = {{ $nodePortListLength }}
{{- end -}}
{{- end -}}
{{/* Validate values of MongoDB&reg; - number of replicas must be the same as clusterIP list */}}
{{- define "mongodb-sharded.validateValues.clusterIPListLength" -}}
{{- $replicaCount := int .Values.mongos.replicaCount }}
{{- $clusterIPListLength := len .Values.mongos.servicePerReplica.clusterIPs }}
{{- if and (gt $clusterIPListLength 0) .Values.mongos.useStatefulSet .Values.mongos.servicePerReplica.enabled (not (eq $replicaCount $clusterIPListLength )) (eq .Values.mongos.servicePerReplica.type "ClusterIP") -}}
mongodb: .Values.mongos.servicePerReplica.clusterIPs
Number of mongos.replicaCount and mongos.servicePerReplica.clusterIPs array length must be the same. Currently: replicaCount = {{ $replicaCount }} and clusterIPs = {{ $clusterIPListLength }}
{{- end -}}
{{- end -}}
{{/* Validate values of MongoDB&reg; - number of replicas must be the same as loadBalancerIP list */}}
{{- define "mongodb-sharded.validateValues.loadBalancerIPListLength" -}}
{{- $replicaCount := int .Values.mongos.replicaCount }}
{{- $loadBalancerIPListLength := len .Values.mongos.servicePerReplica.loadBalancerIPs }}
{{- if and (gt $loadBalancerIPListLength 0) .Values.mongos.useStatefulSet .Values.mongos.servicePerReplica.enabled (not (eq $replicaCount $loadBalancerIPListLength )) (eq .Values.mongos.servicePerReplica.type "LoadBalancer") -}}
mongodb: .Values.mongos.servicePerReplica.loadBalancerIPs
Number of mongos.replicaCount and mongos.servicePerReplica.loadBalancerIPs array length must be the same. Currently: replicaCount = {{ $replicaCount }} and loadBalancerIPs = {{ $loadBalancerIPListLength }}
{{- end -}}
{{- end -}}
{{/* Check if there are rolling tags in the images */}}
{{- define "mongodb-sharded.checkRollingTags" -}}
{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.metrics.image }}
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
{{- end -}}
{{/* Customizations */}}\
{{/* Redirect logs to stdout */}}
{{- define "mongodb-sharded.initContainer.logDir" -}}
- name: log-dir
image: {{ include "mongodb-sharded.image" $ }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /bin/bash
args:
- -ec
- |
ln -sf /dev/stdout "/opt/bitnami/mongodb/logs/mongodb.log"
volumeMounts:
- name: empty-dir
mountPath: /opt/bitnami/mongodb/logs
subPath: app-logs-dir
{{- end }}
{{/* Percona PMM client container definition*/}}
{{- define "mongodb-sharded.pmmClientContainer" -}}
- name: pmm-client
image: {{ .Values.pmmMetrics.image.repository }}:{{ .Values.pmmMetrics.image.tag }}
env:
- name: PMM_AGENT_SERVER_ADDRESS
value: {{ .Values.pmmMetrics.pmm_agent_server_address | quote }}
- name: PMM_AGENT_SERVER_INSECURE_TLS
value: {{ .Values.pmmMetrics.pmm_agent_server_insecure_tls | quote }}
- name: PMM_AGENT_SERVER_USERNAME
valueFrom:
secretKeyRef:
name: mongodb-pmm-credentials
key: pmm-agent-server-username
- name: PMM_AGENT_SERVER_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-pmm-credentials
key: pmm-agent-server-password
- name: PMM_MONGODB_USERNAME
valueFrom:
secretKeyRef:
name: mongodb-pmm-credentials
key: pmm-mongodb-username
- name: PMM_MONGODB_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-pmm-credentials
key: pmm-mongodb-password
- name: PMM_AGENT_SETUP_FORCE
value: {{ .Values.pmmMetrics.pmm_agent_setup_force | quote }}
- name: PMM_AGENT_CONFIG_FILE
value: {{ .Values.pmmMetrics.pmm_agent_config_file | quote }}
- name: PMM_AGENT_PRERUN_SCRIPT
value: {{ .Values.pmmMetrics.pmm_agent_prerun_script | quote }}
startupProbe:
tcpSocket:
port: 27017
initialDelaySeconds: 50
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 30
readinessProbe:
tcpSocket:
port: 27017
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
{{- end }}

View File

@@ -0,0 +1,20 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and (not .Values.configsvr.external.host) .Values.configsvr.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-configsvr" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: configsvr
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
mongodb.conf: |-
{{- include "common.tplvalues.render" (dict "value" .Values.configsvr.config "context" $) | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,28 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and (not .Values.configsvr.external.host) .Values.configsvr.pdb.create }}
kind: PodDisruptionBudget
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
metadata:
name: {{ printf "%s-configsvr" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: configsvr
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.configsvr.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: configsvr
{{- if .Values.configsvr.pdb.minAvailable }}
minAvailable: {{ .Values.configsvr.pdb.minAvailable | int }}
{{- end }}
{{- if .Values.configsvr.pdb.maxUnavailable }}
maxUnavailable: {{ .Values.configsvr.pdb.maxUnavailable | int }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,37 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and (not .Values.configsvr.external.host) (and .Values.metrics.enabled .Values.metrics.podMonitor.enabled) }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ printf "%s-configsvr" (include "common.names.fullname" .) }}
namespace: {{ default .Release.Namespace .Values.metrics.podMonitor.namespace | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: configsvr
{{- if .Values.metrics.podMonitor.additionalLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.podMonitor.additionalLabels "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
podMetricsEndpoints:
- port: metrics
path: /metrics
{{- if .Values.metrics.podMonitor.interval }}
interval: {{ .Values.metrics.podMonitor.interval }}
{{- end }}
{{- if .Values.metrics.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.podMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.configsvr.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: configsvr
{{- end }}

View File

@@ -0,0 +1,465 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if not .Values.configsvr.external.host }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ printf "%s-configsvr" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: configsvr
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.configsvr.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: configsvr
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
replicas: {{ .Values.configsvr.replicaCount }}
podManagementPolicy: {{ .Values.configsvr.podManagementPolicy }}
updateStrategy: {{- toYaml .Values.configsvr.updateStrategy | nindent 4 }}
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
app.kubernetes.io/component: configsvr
{{- if or .Values.common.podAnnotations .Values.configsvr.podAnnotations .Values.metrics.enabled }}
annotations:
{{- if or .Values.common.podAnnotations .Values.configsvr.podAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.configsvr.podAnnotations .Values.common.podAnnotations ) "context" . ) }}
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.metrics.enabled }}
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
spec:
{{- if .Values.configsvr.schedulerName }}
schedulerName: {{ .Values.configsvr.schedulerName | quote }}
{{- end }}
serviceAccountName: {{ include "mongodb-sharded.serviceAccountName" (dict "component" "configsvr" "value" .Values.configsvr.serviceAccount "context" $) }}
automountServiceAccountToken: {{ .Values.configsvr.automountServiceAccountToken }}
{{- if .Values.configsvr.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.configsvr.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.configsvr.podAffinityPreset "component" "configsvr" "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.configsvr.podAntiAffinityPreset "component" "configsvr" "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.configsvr.nodeAffinityPreset.type "key" .Values.configsvr.nodeAffinityPreset.key "values" .Values.configsvr.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.configsvr.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.configsvr.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.configsvr.priorityClassName }}
priorityClassName: {{ .Values.configsvr.priorityClassName | quote }}
{{- end }}
{{- if .Values.configsvr.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.topologySpreadConstraints "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.configsvr.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.configsvr.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.configsvr.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.configsvr.terminationGracePeriodSeconds }}
{{- end }}
{{- include "mongodb-sharded.imagePullSecrets" . | nindent 6 }}
initContainers:
{{- if and .Values.volumePermissions.enabled .Values.configsvr.persistence.enabled }}
- name: volume-permissions
image: {{ include "mongodb-sharded.volumePermissions.image" . }}
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command:
- /bin/bash
args:
- -ec
- |
mkdir -p {{ .Values.configsvr.persistence.mountPath }}{{- if .Values.configsvr.persistence.subPath }}/{{ include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.subPath "context" $) }}{{- end }}
chown {{ .Values.configsvr.containerSecurityContext.runAsUser }}:{{ .Values.configsvr.podSecurityContext.fsGroup }} {{ .Values.configsvr.persistence.mountPath }}{{- if .Values.configsvr.persistence.subPath }}/{{ include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.subPath "context" $) }}{{- end }}
find {{ .Values.configsvr.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.configsvr.containerSecurityContext.runAsUser }}:{{ .Values.configsvr.podSecurityContext.fsGroup }}
securityContext:
runAsUser: 0
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
{{- else if ne .Values.volumePermissions.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.volumePermissions.resourcesPreset) | nindent 12 }}
{{- end }}
volumeMounts:
- name: datadir
mountPath: {{ .Values.configsvr.persistence.mountPath }}
{{- if .Values.configsvr.persistence.subPath }}
subPath: {{ include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.subPath "context" $) }}
{{- end }}
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- end }}
{{- with .Values.configsvr.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with .Values.common.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- include "mongodb-sharded.initContainer.logDir" $ | nindent 8 }}
containers:
- name: mongodb
image: {{ include "mongodb-sharded.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.configsvr.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.configsvr.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ .Values.common.containerPorts.mongodb }}
name: mongodb
env:
- name: GLIBC_TUNABLES
value: glibc.pthread.rseq=0
- name: MONGODB_ENABLE_NUMACTL
value: {{ ternary "yes" "no" .Values.common.mongodbEnableNumactl | quote }}
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.common.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.common.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_INIT_RETRY_ATTEMPTS
value: {{ .Values.common.mongodbInitRetryAttempts | quote }}
- name: MONGODB_INIT_RETRY_DELAY
value: {{ .Values.common.mongodbInitRetryDelay | quote }}
- name: MONGODB_SHARDING_MODE
value: "configsvr"
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_PORT_NUMBER
value: {{ .Values.common.containerPorts.mongodb | quote }}
- name: MONGODB_INITIAL_PRIMARY_HOST
value: {{ include "mongodb-sharded.configServer.primaryHost" . }}
- name: MONGODB_REPLICA_SET_NAME
value: {{ printf "%s-configsvr" ( include "common.names.fullname" . ) }}
{{- if .Values.common.useHostnames }}
- name: MONGODB_ADVERTISED_HOSTNAME
value: {{ printf "$(MONGODB_POD_NAME).%s-headless.%s.svc.%s" (include "common.names.fullname" .) (include "common.names.namespace" .) .Values.clusterDomain }}
{{- end }}
{{- if .Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
{{- if .Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
- name: MONGODB_REPLICA_SET_KEY_FILE
value: "/bitnami/mongodb/secrets/mongodb-replica-set-key"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-replica-set-key
{{- end }}
{{- end }}
- name: MONGODB_ENABLE_IPV6
{{- if .Values.common.mongodbEnableIPv6 }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.common.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.configsvr.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS
value: {{ .Values.configsvr.mongodbExtraFlags | join " " | quote }}
{{- end }}
{{- if .Values.common.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if .Values.configsvr.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.configsvr.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if or .Values.common.extraEnvVarsCM .Values.common.extraEnvVarsSecret .Values.configsvr.extraEnvVarsCM .Values.configsvr.extraEnvVarsSecret }}
envFrom:
{{- if .Values.common.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if .Values.common.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- if .Values.configsvr.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.configsvr.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if .Values.configsvr.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.configsvr.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
{{- if .Values.configsvr.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.configsvr.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.args "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.configsvr.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.customLivenessProbe "context" $) | nindent 12 }}
{{- else if .Values.configsvr.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.configsvr.livenessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- pgrep
- mongod
{{- end }}
{{- if .Values.configsvr.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.customReadinessProbe "context" $) | nindent 12 }}
{{- else if .Values.configsvr.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.configsvr.readinessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
{{- end }}
{{- if .Values.configsvr.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.configsvr.customStartupProbe "context" $) | nindent 12 }}
{{- else if .Values.configsvr.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.configsvr.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: mongodb
{{- end }}
{{- end }}
{{- if $.Values.configsvr.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" $.Values.configsvr.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/conf
subPath: app-conf-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/tmp
subPath: app-tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/logs
subPath: app-logs-dir
- name: empty-dir
mountPath: /.mongodb
subPath: app-mongosh-dir
- name: replicaset-entrypoint-configmap
mountPath: /entrypoint
- name: datadir
mountPath: {{ .Values.configsvr.persistence.mountPath }}
{{- if .Values.configsvr.persistence.subPath }}
subPath: {{ include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.subPath "context" $) }}
{{- end }}
{{- if or .Values.configsvr.config .Values.configsvr.configCM }}
- name: config
mountPath: /bitnami/mongodb/conf/
{{- end }}
{{- if .Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
{{- if .Values.common.initScriptsCM }}
- name: custom-init-scripts-cm
mountPath: /docker-entrypoint-initdb.d/cm
{{- end }}
{{- if .Values.common.initScriptsSecret }}
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/secret
{{- end }}
{{- if .Values.common.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" .Values.common.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if .Values.configsvr.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" .Values.configsvr.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if .Values.configsvr.resources }}
resources: {{- toYaml .Values.configsvr.resources | nindent 12 }}
{{- else if ne .Values.configsvr.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.configsvr.resourcesPreset) | nindent 12 }}
{{- end }}
{{- if $.Values.pmmMetrics.enabled | default false }}
{{- include "mongodb-sharded.pmmClientContainer" $ | nindent 8 }}
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
image: {{ include "mongodb-sharded.metrics.image" . }}
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
{{- if .Values.metrics.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.metrics.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
env:
{{- if .Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
{{- if .Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-root-password
{{- end }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
command:
- sh
- -ec
- |-
#!/bin/sh
{{- if .Values.auth.usePasswordFiles }}
export MONGODB_ROOT_PASSWORD="$(cat "${MONGODB_ROOT_PASSWORD_FILE}")"
{{- end }}
/bin/mongodb_exporter --collect-all --compatible-mode --web.listen-address ":{{ .Values.metrics.containerPorts.metrics }}" --mongodb.uri mongodb://$(echo $MONGODB_ROOT_USER):$(echo $MONGODB_ROOT_PASSWORD | sed -r "s/@/%40/g;s/:/%3A/g")@localhost:{{ .Values.common.containerPorts.mongodb }}/admin{{ ternary "?ssl=true" "" $.Values.metrics.useTLS }} {{ .Values.metrics.extraArgs }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if .Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
ports:
- name: metrics
containerPort: {{ .Values.metrics.containerPorts.metrics }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.metrics.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
{{- else if .Values.metrics.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- if .Values.metrics.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
{{- else if .Values.metrics.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
httpGet:
path: /metrics
port: metrics
{{- end }}
{{- if .Values.metrics.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
{{- else if .Values.metrics.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- end }}
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- else if ne .Values.metrics.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.metrics.resourcesPreset) | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.configsvr.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with .Values.common.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
volumes:
- name: empty-dir
emptyDir: {}
- name: replicaset-entrypoint-configmap
configMap:
name: {{ printf "%s-replicaset-entrypoint" (include "common.names.fullname" .) }}
{{- if .Values.auth.usePasswordFiles }}
- name: secrets
secret:
secretName: {{ include "mongodb-sharded.secret" . }}
{{- end }}
{{- if or .Values.configsvr.config .Values.configsvr.configCM }}
- name: config
configMap:
name: {{ include "mongodb-sharded.configsvr.configCM" . }}
{{- end }}
{{- if .Values.common.initScriptsCM }}
- name: custom-init-scripts-cm
configMap:
name: {{ include "mongodb-sharded.initScriptsCM" . }}
defaultMode: 0755
{{- end }}
{{- if .Values.common.initScriptsSecret }}
- name: custom-init-scripts-secret
secret:
secretName: {{ include "mongodb-sharded.initScriptsSecret" . }}
defaultMode: 0755
{{- end }}
{{- if .Values.common.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" .Values.common.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.configsvr.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" .Values.configsvr.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if not .Values.configsvr.persistence.enabled }}
- name: datadir
emptyDir: {}
{{- else }}
{{- if .Values.configsvr.persistentVolumeClaimRetentionPolicy.enabled }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.configsvr.persistentVolumeClaimRetentionPolicy.whenDeleted }}
whenScaled: {{ .Values.configsvr.persistentVolumeClaimRetentionPolicy.whenScaled }}
{{- end }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: datadir
{{- if or .Values.configsvr.persistence.annotations .Values.commonAnnotations .Values.configsvr.persistence.resourcePolicy }}
{{- if or .Values.commonAnnotations .Values.configsvr.persistence.annotations .Values.configsvr.persistence.resourcePolicy }}
annotations:
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 10 }}
{{- end }}
{{- if .Values.configsvr.persistence.annotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.configsvr.persistence.annotations "context" $) | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
spec:
accessModes:
{{- range .Values.configsvr.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.configsvr.persistence.size | quote }}
{{- include "common.storage.class" (dict "persistence" .Values.configsvr.persistence "global" .Values.global) | nindent 8 }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,9 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- range .Values.extraDeploy }}
---
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}

View File

@@ -0,0 +1,26 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: v1
kind: Service
metadata:
name: {{ printf "%s-headless" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.commonAnnotations .Values.service.headless.annotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.headless.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: mongodb
port: {{ .Values.service.ports.mongodb }}
{{- if .Values.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}

View File

@@ -0,0 +1,20 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.mongos.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-mongos" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
mongodb.conf: |-
{{- include "common.tplvalues.render" (dict "value" .Values.mongos.config "context" $) | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,374 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: {{ if .Values.mongos.useStatefulSet }}{{ include "common.capabilities.statefulset.apiVersion" . }}{{- else }}{{ include "common.capabilities.deployment.apiVersion" . }}{{- end }}
kind: {{ if .Values.mongos.useStatefulSet }}StatefulSet{{- else }}Deployment{{- end }}
metadata:
name: {{ printf "%s-mongos" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if .Values.mongos.useStatefulSet }}
serviceName: {{ include "mongodb-sharded.serviceName" . }}
podManagementPolicy: {{ .Values.mongos.podManagementPolicy }}
updateStrategy:
{{- else }}
strategy:
{{- end }}
{{- toYaml .Values.mongos.updateStrategy | nindent 4 }}
replicas: {{ .Values.mongos.replicaCount }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.mongos.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: mongos
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
app.kubernetes.io/component: mongos
{{- if or .Values.common.podAnnotations .Values.mongos.podAnnotations .Values.metrics.enabled }}
annotations:
{{- if or .Values.common.podAnnotations .Values.mongos.podAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.mongos.podAnnotations .Values.common.podAnnotations ) "context" . ) }}
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.metrics.enabled }}
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
spec:
{{- if .Values.mongos.schedulerName }}
schedulerName: {{ .Values.mongos.schedulerName | quote }}
{{- end }}
serviceAccountName: {{ include "mongodb-sharded.serviceAccountName" (dict "component" "mongos" "value" $.Values.mongos.serviceAccount "context" $) }}
automountServiceAccountToken: {{ .Values.mongos.automountServiceAccountToken }}
{{- if .Values.mongos.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.mongos.podAffinityPreset "component" "mongos" "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.mongos.podAntiAffinityPreset "component" "mongos" "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.mongos.nodeAffinityPreset.type "key" .Values.mongos.nodeAffinityPreset.key "values" .Values.mongos.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.mongos.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.priorityClassName }}
priorityClassName: {{ .Values.mongos.priorityClassName | quote }}
{{- end }}
{{- if .Values.mongos.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.topologySpreadConstraints "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.mongos.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.mongos.terminationGracePeriodSeconds }}
{{- end }}
{{- include "mongodb-sharded.imagePullSecrets" . | nindent 6 }}
initContainers:
{{- with $.Values.mongos.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- include "mongodb-sharded.initContainer.logDir" $ | nindent 8 }}
containers:
- name: mongos
image: {{ include "mongodb-sharded.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.mongos.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.mongos.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
env:
- name: GLIBC_TUNABLES
value: glibc.pthread.rseq=0
- name: MONGODB_ENABLE_NUMACTL
value: {{ ternary "yes" "no" $.Values.common.mongodbEnableNumactl | quote }}
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
- name: MONGODB_SHARDING_MODE
value: "mongos"
- name: MONGODB_INIT_RETRY_ATTEMPTS
value: {{ .Values.common.mongodbInitRetryAttempts | quote }}
- name: MONGODB_INIT_RETRY_DELAY
value: {{ .Values.common.mongodbInitRetryDelay | quote }}
{{- if $.Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
{{- if .Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
- name: MONGODB_REPLICA_SET_KEY_FILE
value: "/bitnami/mongodb/secrets/mongodb-replica-set-key"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-replica-set-key
{{- end }}
{{- end }}
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- if .Values.common.useHostnames }}
- name: MONGODB_ADVERTISED_HOSTNAME
value: "$(MONGODB_POD_NAME)"
{{- end }}
- name: MONGODB_PORT_NUMBER
value: {{ $.Values.common.containerPorts.mongodb | quote }}
- name: MONGODB_CFG_PRIMARY_HOST
value: {{ include "mongodb-sharded.configServer.primaryHost" . }}
- name: MONGODB_CFG_REPLICA_SET_NAME
value: {{ include "mongodb-sharded.configServer.rsName" . }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.common.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.common.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_IPV6
{{- if .Values.common.mongodbEnableIPv6 }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.common.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongos.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS
value: {{ .Values.mongos.mongodbExtraFlags | join " " | quote }}
{{- end }}
{{- if .Values.common.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if .Values.mongos.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.mongos.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if or .Values.common.extraEnvVarsCM .Values.common.extraEnvVarsSecret .Values.mongos.extraEnvVarsCM .Values.mongos.extraEnvVarsSecret }}
envFrom:
{{- if .Values.common.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if .Values.common.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- if .Values.configsvr.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.mongos.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if .Values.mongos.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.mongos.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- end }}
ports:
- name: mongodb
containerPort: {{ $.Values.common.containerPorts.mongodb }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
{{- if .Values.mongos.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.mongos.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.args "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.mongos.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.customLivenessProbe "context" $) | nindent 12 }}
{{- else if .Values.mongos.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.mongos.livenessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- pgrep
- mongos
{{- end }}
{{- if .Values.mongos.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.customReadinessProbe "context" $) | nindent 12 }}
{{- else if .Values.mongos.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.mongos.readinessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
{{- end }}
{{- if .Values.mongos.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.customStartupProbe "context" $) | nindent 12 }}
{{- else if .Values.mongos.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.mongos.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: mongodb
{{- end }}
{{- end }}
{{- if .Values.mongos.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/conf
subPath: app-conf-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/tmp
subPath: app-tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/logs
subPath: app-logs-dir
- name: empty-dir
mountPath: /.mongodb
subPath: app-mongosh-dir
{{- if .Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
{{- if or .Values.mongos.config .Values.mongos.configCM }}
- name: config
mountPath: /bitnami/mongodb/conf/
{{- end }}
{{- if $.Values.common.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.mongos.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.mongos.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if .Values.mongos.resources }}
resources: {{- toYaml .Values.mongos.resources | nindent 12 }}
{{- else if ne .Values.mongos.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.mongos.resourcesPreset) | nindent 12 }}
{{- end }}
{{- if $.Values.pmmMetrics.enabled | default false }}
{{- include "mongodb-sharded.pmmClientContainer" $ | nindent 8 }}
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
image: {{ include "mongodb-sharded.metrics.image" . }}
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
{{- if .Values.metrics.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.metrics.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
env:
{{- if $.Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
{{- if .Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-root-password
{{- end }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
command:
- sh
- -ec
- |-
#!/bin/sh
{{- if .Values.auth.usePasswordFiles }}
export MONGODB_ROOT_PASSWORD="$(cat "${MONGODB_ROOT_PASSWORD_FILE}")"
{{- end }}
/bin/mongodb_exporter --collect-all --compatible-mode --web.listen-address ":{{ .Values.metrics.containerPorts.metrics }}" --mongodb.uri mongodb://$(echo $MONGODB_ROOT_USER):$(echo $MONGODB_ROOT_PASSWORD | sed -r "s/@/%40/g;s/:/%3A/g")@localhost:{{ .Values.common.containerPorts.mongodb }}/admin{{ ternary "?ssl=true" "" $.Values.metrics.useTLS }} {{ .Values.metrics.extraArgs }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if .Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
ports:
- name: metrics
containerPort: {{ .Values.metrics.containerPorts.metrics }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.metrics.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
{{- else if .Values.metrics.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- if .Values.metrics.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
{{- else if .Values.metrics.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
httpGet:
path: /metrics
port: metrics
{{- end }}
{{- if .Values.metrics.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
{{- else if .Values.metrics.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- end }}
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- else if ne .Values.metrics.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.metrics.resourcesPreset) | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.mongos.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with .Values.common.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
volumes:
- name: empty-dir
emptyDir: {}
{{- if .Values.auth.usePasswordFiles }}
- name: secrets
secret:
secretName: {{ include "mongodb-sharded.secret" . }}
{{- end }}
{{- if or .Values.mongos.config .Values.mongos.configCM }}
- name: config
configMap:
name: {{ include "mongodb-sharded.mongos.configCM" . }}
{{- end }}
{{- if $.Values.common.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.mongos.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.mongos.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,28 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.mongos.pdb.create }}
kind: PodDisruptionBudget
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
metadata:
name: {{ printf "%s-mongos" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.mongos.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: mongos
{{- if .Values.mongos.pdb.minAvailable }}
minAvailable: {{ .Values.mongos.pdb.minAvailable | int }}
{{- end }}
{{- if .Values.mongos.pdb.maxUnavailable }}
maxUnavailable: {{ .Values.mongos.pdb.maxUnavailable | int }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,37 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.metrics.enabled .Values.metrics.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ printf "%s-mongos" (include "common.names.fullname" .) }}
namespace: {{ default .Release.Namespace .Values.metrics.podMonitor.namespace | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if .Values.metrics.podMonitor.additionalLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.podMonitor.additionalLabels "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
podMetricsEndpoints:
- port: metrics
path: /metrics
{{- if .Values.metrics.podMonitor.interval }}
interval: {{ .Values.metrics.podMonitor.interval }}
{{- end }}
{{- if .Values.metrics.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.podMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.mongos.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: mongos
{{- end }}

View File

@@ -0,0 +1,67 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.mongos.useStatefulSet .Values.mongos.servicePerReplica.enabled }}
{{- range $i := until (.Values.mongos.replicaCount | int) }}
{{- $context := deepCopy $ | merge (dict "index" $i) }}
apiVersion: v1
kind: Service
metadata:
name: {{ printf "%s-%d" (include "mongodb-sharded.serviceName" $) $i }}
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if or $.Values.commonAnnotations $.Values.mongos.servicePerReplica.annotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $.Values.mongos.servicePerReplica.annotations $.Values.commonAnnotations ) "context" $ ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: {{ $.Values.mongos.servicePerReplica.type }}
sessionAffinity: {{ default "None" $.Values.mongos.servicePerReplica.sessionAffinity }}
{{- if $.Values.mongos.servicePerReplica.sessionAffinityConfig }}
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.servicePerReplica.sessionAffinityConfig "context" $context) | nindent 4 }}
{{- end }}
{{- if or (eq $.Values.mongos.servicePerReplica.type "LoadBalancer") (eq $.Values.mongos.servicePerReplica.type "NodePort") }}
externalTrafficPolicy: {{ $.Values.mongos.servicePerReplica.externalTrafficPolicy | quote }}
{{- end }}
{{- if $.Values.mongos.servicePerReplica.externalIPs }}
externalIPs: {{- toYaml $.Values.mongos.servicePerReplica.externalIPs | nindent 4 }}
{{- end }}
{{- if and $.Values.mongos.servicePerReplica.loadBalancerIPs (eq $.Values.mongos.servicePerReplica.type "LoadBalancer") }}
loadBalancerIP: {{ index $.Values.mongos.servicePerReplica.loadBalancerIPs $i }}
{{- end }}
{{- if and (eq $.Values.mongos.servicePerReplica.type "LoadBalancer") $.Values.mongos.servicePerReplica.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ with $.Values.mongos.servicePerReplica.loadBalancerSourceRanges }}
{{ include "common.tplvalues.render" . | nindent 4 }}
{{- end }}
{{- end }}
{{- if and (eq $.Values.mongos.servicePerReplica.type "ClusterIP") $.Values.mongos.servicePerReplica.clusterIPs }}
clusterIP: {{ index $.Values.mongos.servicePerReplica.clusterIPs $i }}
{{- end }}
ports:
- name: mongodb
port: {{ $.Values.mongos.servicePerReplica.port }}
targetPort: mongodb
{{- if $.Values.mongos.servicePerReplica.nodePorts }}
nodePort: {{ index $.Values.mongos.servicePerReplica.nodePorts $i }}
{{- else if eq $.Values.mongos.servicePerReplica.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if $.Values.metrics.enabled }}
- name: metrics
port: 9216
targetPort: metrics
{{- end }}
{{- if $.Values.mongos.servicePerReplica.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" $.Values.mongos.servicePerReplica.extraPorts "context" $context) | nindent 4 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.mongos.podLabels $.Values.common.podLabels $.Values.commonLabels ) "context" $ ) }}
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
statefulset.kubernetes.io/pod-name: {{ printf "%s-mongos-%d" (include "common.names.fullname" $) $i }}
---
{{- end }}
{{- end }}

View File

@@ -0,0 +1,65 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mongodb-sharded.serviceName" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if or .Values.commonAnnotations .Values.service.annotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ with .Values.service.loadBalancerSourceRanges }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end }}
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs: {{- toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
ports:
- name: mongodb
port: {{ .Values.service.ports.mongodb }}
targetPort: mongodb
{{- if .Values.service.nodePorts.mongodb }}
nodePort: {{ .Values.service.nodePorts.mongodb }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
port: 9216
targetPort: metrics
{{- if .Values.service.nodePorts.metrics }}
nodePort: {{ .Values.service.nodePorts.metrics }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- end }}
{{- if .Values.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.mongos.podLabels .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongos
sessionAffinity: {{ default "None" .Values.service.sessionAffinity }}
{{- if .Values.service.sessionAffinityConfig }}
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
{{- end }}
{{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}

View File

@@ -0,0 +1,75 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ template "common.names.namespace" . }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.common.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
policyTypes:
- Ingress
- Egress
{{- if .Values.networkPolicy.allowExternalEgress }}
egress:
- {}
{{- else }}
egress:
# Allow dns resolution
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow connection to other cluster pods
- ports:
- port: {{ .Values.common.containerPorts.mongodb }}
to:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
{{- if .Values.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.rts.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
ingress:
- ports:
- port: {{ .Values.common.containerPorts.mongodb }}
{{- if .Values.metrics.enabled }}
- port: {{ .Values.metrics.containerPorts.metrics }}
{{- end }}
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels:
{{ template "common.names.fullname" . }}-client: "true"
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
{{- if .Values.networkPolicy.ingressNSMatchLabels }}
- namespaceSelector:
matchLabels:
{{- range $key, $value := .Values.networkPolicy.ingressNSMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- if .Values.networkPolicy.ingressNSPodMatchLabels }}
podSelector:
matchLabels:
{{- range $key, $value := .Values.networkPolicy.ingressNSPodMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,39 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-replicaset-entrypoint" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
replicaset-entrypoint.sh: |-
#!/bin/bash
sleep 5
. /liblog.sh
# Perform adaptations depending on the host name
if [[ $HOSTNAME =~ (.*)-0$ ]]; then
info "Setting node as primary"
export MONGODB_REPLICA_SET_MODE=primary
else
info "Setting node as secondary"
export MONGODB_REPLICA_SET_MODE=secondary
{{- if .Values.auth.usePasswordFiles }}
export MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD_FILE="$MONGODB_ROOT_PASSWORD_FILE"
unset MONGODB_ROOT_PASSWORD_FILE
{{- else }}
export MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD="$MONGODB_ROOT_PASSWORD"
unset MONGODB_ROOT_PASSWORD
{{- end }}
fi
exec /entrypoint.sh /run.sh

View File

@@ -0,0 +1,29 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if not .Values.auth.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: mongodb
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- if .Values.configsvr.external.rootPassword }}
mongodb-root-password: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "mongodb-root-password" "providedValues" (list "configsvr.external.rootPassword" ) "context" $) }}
{{- else }}
mongodb-root-password: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "mongodb-root-password" "providedValues" (list "auth.rootPassword" ) "context" $) }}
{{- end }}
{{- if .Values.configsvr.external.replicasetKey }}
mongodb-replica-set-key: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "mongodb-replica-set-key" "providedValues" (list "configsvr.external.replicasetKey" ) "context" $) }}
{{- else }}
mongodb-replica-set-key: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "mongodb-replica-set-key" "providedValues" (list "auth.replicaSetKey" ) "context" $) }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,22 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- range $component,$serviceAccount:=(dict "common" .Values.common.serviceAccount "mongos" .Values.mongos.serviceAccount "configsvr" .Values.configsvr.serviceAccount "shardsvr-arbiter" .Values.shardsvr.arbiter.serviceAccount "shardsvr" .Values.shardsvr.dataNode.serviceAccount) }}
{{- if $serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "mongodb-sharded.serviceAccountName" (dict "component" $component "value" $serviceAccount "context" $) }}
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: {{ $component }}
{{- if or $serviceAccount.annotations $.Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $serviceAccount.annotations $.Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ $serviceAccount.automountServiceAccountToken }}
---
{{- end }}
{{- end }}

View File

@@ -0,0 +1,20 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.shards .Values.shardsvr.arbiter.replicaCount .Values.shardsvr.arbiter.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-shardsvr-arbiter" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: shardsvr-arbiter
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
mongodb.conf: |-
{{- include "common.tplvalues.render" (dict "value" .Values.shardsvr.arbiter.config "context" $) | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,394 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.shards .Values.shardsvr.arbiter.replicaCount }}
{{- $replicas := $.Values.shards | int }}
{{- range $i, $e := until $replicas }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ printf "%s-shard%d-arbiter" (include "common.names.fullname" $ ) $i }}
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: shardsvr-arbiter
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.shardsvr.arbiter.podLabels $.Values.common.podLabels $.Values.common.podLabels ) "context" $ ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: shardsvr-arbiter
podManagementPolicy: {{ $.Values.shardsvr.arbiter.podManagementPolicy }}
updateStrategy: {{- toYaml $.Values.shardsvr.arbiter.updateStrategy | nindent 4 }}
serviceName: {{ printf "%s-headless" (include "common.names.fullname" $) }}
replicas: {{ $.Values.shardsvr.arbiter.replicaCount }}
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
app.kubernetes.io/component: shardsvr-arbiter
shard: {{ $i | quote }}
{{- if or $.Values.common.podAnnotations $.Values.shardsvr.arbiter.podAnnotations $.Values.metrics.enabled }}
annotations:
{{- if or $.Values.common.podAnnotations $.Values.shardsvr.arbiter.podAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $.Values.shardsvr.arbiter.podAnnotations $.Values.common.podAnnotations ) "context" $ ) }}
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.metrics.enabled }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
spec:
serviceAccountName: {{ include "mongodb-sharded.serviceAccountName" (dict "component" "shardsvr-arbiter" "value" $.Values.shardsvr.arbiter.serviceAccount "context" $) }}
{{- if $.Values.shardsvr.arbiter.schedulerName }}
schedulerName: {{ $.Values.shardsvr.arbiter.schedulerName | quote }}
{{- end }}
automountServiceAccountToken: {{ $.Values.shardsvr.arbiter.automountServiceAccountToken }}
{{- if $.Values.shardsvr.arbiter.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.affinity "context" (set $ "arbiterLoopId" $i)) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" $.Values.shardsvr.arbiter.podAffinityPreset "component" "shardsvr-arbiter" "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" $.Values.shardsvr.arbiter.podAntiAffinityPreset "component" "shardsvr-arbiter" "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" $.Values.shardsvr.arbiter.nodeAffinityPreset.type "key" $.Values.shardsvr.arbiter.nodeAffinityPreset.key "values" $.Values.shardsvr.arbiter.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.priorityClassName }}
priorityClassName: {{ $.Values.shardsvr.arbiter.priorityClassName | quote }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.topologySpreadConstraints "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.shardsvr.arbiter.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ $.Values.shardsvr.arbiter.terminationGracePeriodSeconds }}
{{- end }}
{{- include "mongodb-sharded.imagePullSecrets" $ | nindent 6 }}
{{- if or $.Values.shardsvr.arbiter.initContainers $.Values.common.initContainers }}
initContainers:
{{- with $.Values.shardsvr.arbiter.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
containers:
- name: {{ printf "%s-arbiter" (include "common.names.fullname" $) }}
image: {{ include "mongodb-sharded.image" $ }}
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- if $.Values.shardsvr.arbiter.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.shardsvr.arbiter.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ $.Values.common.containerPorts.mongodb }}
name: mongodb
env:
- name: MONGODB_ENABLE_NUMACTL
value: {{ ternary "yes" "no" $.Values.common.mongodbEnableNumactl | quote }}
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or $.Values.image.debug $.Values.diagnosticMode.enabled) | quote }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ $.Values.common.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if $.Values.common.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_INIT_RETRY_ATTEMPTS
value: {{ $.Values.common.mongodbInitRetryAttempts | quote }}
- name: MONGODB_INIT_RETRY_DELAY
value: {{ $.Values.common.mongodbInitRetryDelay | quote }}
- name: MONGODB_SHARDING_MODE
value: "shardsvr"
- name: MONGODB_REPLICA_SET_MODE
value: "arbiter"
- name: MONGODB_PORT_NUMBER
value: {{ $.Values.common.containerPorts.mongodb | quote }}
- name: MONGODB_INITIAL_PRIMARY_HOST
value: {{ printf "%s-shard%d-data-0.%s-headless.%s.svc.%s" (include "common.names.fullname" $ ) $i (include "common.names.fullname" $ ) $.Release.Namespace $.Values.clusterDomain }}
- name: MONGODB_REPLICA_SET_NAME
value: {{ printf "%s-shard-%d" ( include "common.names.fullname" $ ) $i }}
{{- if $.Values.common.useHostnames }}
- name: MONGODB_ADVERTISED_HOSTNAME
value: {{ printf "$(MONGODB_POD_NAME).%s-headless.%s.svc.%s" (include "common.names.fullname" $) (include "common.names.namespace" $) $.Values.clusterDomain }}
{{- end }}
- name: MONGODB_ENABLE_IPV6
{{- if $.Values.common.mongodbEnableIPv6 }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if $.Values.common.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if $.Values.auth.enabled }}
- name: MONGODB_INITIAL_PRIMARY_ROOT_USER
value: {{ $.Values.auth.rootUser | quote }}
{{- if $.Values.auth.usePasswordFiles }}
- name: MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
- name: MONGODB_REPLICA_SET_KEY_FILE
value: "/bitnami/mongodb/secrets/mongodb-replica-set-key"
{{- else }}
- name: MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" $ }}
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" $ }}
key: mongodb-replica-set-key
{{- end }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS
value: {{ $.Values.shardsvr.arbiter.mongodbExtraFlags | join " " | quote }}
{{- end }}
{{- if $.Values.common.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.arbiter.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if or $.Values.common.extraEnvVarsCM $.Values.common.extraEnvVarsSecret $.Values.shardsvr.arbiter.extraEnvVarsCM $.Values.shardsvr.arbiter.extraEnvVarsSecret }}
envFrom:
{{- if $.Values.common.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if $.Values.common.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.arbiter.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.arbiter.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- end }}
{{- if $.Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
{{- if $.Values.shardsvr.arbiter.command }}
command: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.command "context" $) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.args }}
args: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.args "context" $) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.customLivenessProbe "context" $) | nindent 12 }}
{{- else if $.Values.shardsvr.arbiter.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.shardsvr.arbiter.livenessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- pgrep
- -f
- mongodb
{{- end }}
{{- if $.Values.shardsvr.arbiter.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.customReadinessProbe "context" $) | nindent 12 }}
{{- else if $.Values.shardsvr.arbiter.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.shardsvr.arbiter.readinessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: mongodb
{{- end }}
{{- if $.Values.shardsvr.arbiter.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.customStartupProbe "context" $) | nindent 12 }}
{{- else if $.Values.shardsvr.arbiter.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.shardsvr.arbiter.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: mongodb
{{- end }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.arbiter.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/conf
subPath: app-conf-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/tmp
subPath: app-tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/logs
subPath: app-logs-dir
- name: empty-dir
mountPath: /.mongodb
subPath: app-mongosh-dir
{{- if or $.Values.shardsvr.arbiter.config $.Values.shardsvr.arbiter.configCM }}
- name: config
mountPath: /bitnami/mongodb/conf/
{{- end }}
{{- if $.Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
{{- if $.Values.common.initScriptsCM }}
- name: custom-init-scripts-cm
mountPath: /docker-entrypoint-initdb.d/cm
{{- end }}
{{- if $.Values.common.initScriptsSecret }}
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/secret
{{- end }}
{{- if $.Values.common.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.arbiter.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.resources }}
resources: {{- toYaml $.Values.shardsvr.arbiter.resources | nindent 12 }}
{{- else if ne $.Values.shardsvr.arbiter.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" $.Values.shardsvr.arbiter.resourcesPreset) | nindent 12 }}
{{- end }}
{{- if $.Values.metrics.enabled }}
- name: metrics
image: {{ include "mongodb-sharded.metrics.image" $ }}
imagePullPolicy: {{ $.Values.metrics.image.pullPolicy | quote }}
{{- if $.Values.metrics.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.metrics.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
env:
{{- if $.Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ $.Values.auth.rootUser | quote }}
{{- if $.Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" $ }}
key: mongodb-root-password
{{- end }}
{{- end }}
{{- if $.Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
command:
- sh
- -ec
- |-
#!/bin/sh
{{- if $.Values.auth.usePasswordFiles }}
export MONGODB_ROOT_PASSWORD="$(cat "${MONGODB_ROOT_PASSWORD_FILE}")"
{{- end }}
/bin/mongodb_exporter --collect-all --compatible-mode --web.listen-address ":{{ $.Values.metrics.containerPorts.metrics }}" --mongodb.uri mongodb://$(echo $MONGODB_ROOT_USER):$(echo $MONGODB_ROOT_PASSWORD | sed -r "s/@/%40/g;s/:/%3A/g")@localhost:{{ $.Values.common.containerPorts.mongodb }}/admin{{ ternary "?ssl=true" "" $.Values.metrics.useTLS }} {{ $.Values.metrics.extraArgs }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if $.Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
ports:
- name: metrics
containerPort: {{ $.Values.metrics.containerPorts.metrics }}
{{- if not $.Values.diagnosticMode.enabled }}
{{- if $.Values.metrics.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
{{- else if $.Values.metrics.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- if $.Values.metrics.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
{{- else if $.Values.metrics.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
httpGet:
path: /metrics
port: metrics
{{- end }}
{{- if $.Values.metrics.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.metrics.customStartupProbe "context" $) | nindent 12 }}
{{- else if $.Values.metrics.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- end }}
{{- if $.Values.metrics.resources }}
resources: {{ toYaml $.Values.metrics.resources | nindent 12 }}
{{- else if ne $.Values.metrics.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" $.Values.metrics.resourcesPreset) | nindent 12 }}
{{- end }}
{{- end }}
{{- with $.Values.shardsvr.arbiter.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
volumes:
- name: empty-dir
emptyDir: {}
{{- if or $.Values.shardsvr.arbiter.config $.Values.shardsvr.arbiter.configCM }}
- name: config
configMap:
name: {{ include "mongodb-sharded.shardsvr.arbiter.configCM" $ }}
{{- end }}
{{- if $.Values.auth.usePasswordFiles }}
- name: secrets
secret:
secretName: {{ include "mongodb-sharded.secret" $ }}
{{- end }}
{{- if $.Values.common.initScriptsCM }}
- name: custom-init-scripts-cm
configMap:
name: {{ include "mongodb-sharded.initScriptsCM" $ }}
defaultMode: 0755
{{- end }}
{{- if $.Values.common.initScriptsSecret }}
- name: custom-init-scripts-secret
secret:
secretName: {{ include "mongodb-sharded.initScriptsSecret" $ }}
defaultMode: 0755
{{- end }}
{{- if $.Values.common.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.arbiter.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.arbiter.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if lt $i (sub $replicas 1) }}
---
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,20 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.shards .Values.shardsvr.dataNode.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-shardsvr-data" (include "common.names.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: shardsvr
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
mongodb.conf: |-
{{- include "common.tplvalues.render" (dict "value" .Values.shardsvr.dataNode.config "context" $) | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,33 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.shards .Values.shardsvr.dataNode.pdb.create }}
{{- $replicas := .Values.shards | int }}
{{- range $i, $e := until $replicas }}
kind: PodDisruptionBudget
apiVersion: {{ include "common.capabilities.policy.apiVersion" $ }}
metadata:
name: {{ printf "%s-shard%d-data" (include "common.names.fullname" $ ) $i }}
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: shardsvr
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.shardsvr.arbiter.podLabels $.Values.common.podLabels $.Values.common.podLabels ) "context" $ ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: shardsvr
shard: {{ $i | quote }}
{{- if $.Values.shardsvr.dataNode.pdb.minAvailable }}
minAvailable: {{ $.Values.shardsvr.dataNode.pdb.minAvailable | int }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.pdb.maxUnavailable }}
maxUnavailable: {{ $.Values.shardsvr.dataNode.pdb.maxUnavailable | int }}
{{- end }}
---
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,42 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.shards .Values.metrics.enabled .Values.metrics.podMonitor.enabled }}
{{- $replicas := .Values.shards | int }}
{{- range $i, $e := until $replicas }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ printf "%s-shard%d-data" (include "common.names.fullname" $ ) $i }}
namespace: {{ default (include "common.names.namespace" $) $.Values.metrics.podMonitor.namespace | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: shardsvr
{{- if $.Values.metrics.podMonitor.additionalLabels }}
{{- include "common.tplvalues.render" (dict "value" $.Values.metrics.podMonitor.additionalLabels "context" $) | nindent 4 }}
{{- end }}
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
podMetricsEndpoints:
- port: metrics
path: /metrics
{{- if $.Values.metrics.podMonitor.interval }}
interval: {{ $.Values.metrics.podMonitor.interval }}
{{- end }}
{{- if $.Values.metrics.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ $.Values.metrics.podMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ $.Release.Namespace }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.shardsvr.arbiter.podLabels $.Values.common.podLabels $.Values.common.podLabels ) "context" $ ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: shardsvr
shard: {{ $i | quote }}
---
{{- end }}
{{- end }}

View File

@@ -0,0 +1,480 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.shards }}
{{- $replicas := .Values.shards | int }}
{{- range $i, $e := until $replicas }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ printf "%s-shard%d-data" (include "common.names.fullname" $ ) $i }}
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: shardsvr
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.shardsvr.dataNode.podLabels $.Values.common.podLabels $.Values.common.podLabels ) "context" $ ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: shardsvr
podManagementPolicy: {{ $.Values.shardsvr.dataNode.podManagementPolicy }}
updateStrategy: {{- toYaml $.Values.shardsvr.dataNode.updateStrategy | nindent 4 }}
serviceName: {{ printf "%s-headless" (include "common.names.fullname" $) }}
replicas: {{ $.Values.shardsvr.dataNode.replicaCount }}
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
app.kubernetes.io/component: shardsvr
shard: {{ $i | quote }}
{{- if or $.Values.common.podAnnotations $.Values.shardsvr.dataNode.podAnnotations $.Values.metrics.enabled }}
annotations:
{{- if or $.Values.common.podAnnotations $.Values.shardsvr.dataNode.podAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $.Values.shardsvr.dataNode.podAnnotations $.Values.common.podAnnotations ) "context" $ ) }}
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.metrics.enabled }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
spec:
{{- if $.Values.shardsvr.dataNode.schedulerName }}
schedulerName: {{ $.Values.shardsvr.dataNode.schedulerName | quote }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.affinity "context" (set $ "dataNodeLoopId" $i)) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" $.Values.shardsvr.dataNode.podAffinityPreset "component" "shardsvr" "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" $.Values.shardsvr.dataNode.podAntiAffinityPreset "component" "shardsvr" "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" $.Values.shardsvr.dataNode.nodeAffinityPreset.type "key" $.Values.shardsvr.dataNode.nodeAffinityPreset.key "values" $.Values.shardsvr.dataNode.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
automountServiceAccountToken: {{ $.Values.shardsvr.dataNode.automountServiceAccountToken }}
{{- if $.Values.shardsvr.dataNode.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.nodeSelector "context" (set $ "dataNodeLoopId" $i)) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.tolerations "context" (set $ "dataNodeLoopId" $i)) | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mongodb-sharded.serviceAccountName" (dict "component" "shardsvr" "value" $.Values.shardsvr.dataNode.serviceAccount "context" $) }}
{{- if $.Values.shardsvr.dataNode.priorityClassName }}
priorityClassName: {{ $.Values.shardsvr.dataNode.priorityClassName | quote }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.topologySpreadConstraints "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.shardsvr.dataNode.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ $.Values.shardsvr.dataNode.terminationGracePeriodSeconds }}
{{- end }}
{{- include "mongodb-sharded.imagePullSecrets" $ | nindent 6 }}
initContainers:
{{- if and $.Values.volumePermissions.enabled $.Values.shardsvr.persistence.enabled }}
- name: volume-permissions
image: {{ include "mongodb-sharded.volumePermissions.image" $ }}
imagePullPolicy: {{ $.Values.volumePermissions.image.pullPolicy | quote }}
command:
- /bin/bash
args:
- -ec
- |
mkdir -p {{ $.Values.shardsvr.persistence.mountPath }}{{- if $.Values.shardsvr.persistence.subPath }}/{{ include "common.tplvalues.render" (dict "value" $.Values.shardsvr.persistence.subPath "context" $) }}{{- end }}
chown {{ $.Values.shardsvr.dataNode.containerSecurityContext.runAsUser }}:{{ $.Values.shardsvr.dataNode.podSecurityContext.fsGroup }} {{ $.Values.shardsvr.persistence.mountPath }}{{- if $.Values.shardsvr.persistence.subPath }}/{{ include "common.tplvalues.render" (dict "value" $.Values.shardsvr.persistence.subPath "context" $) }}{{- end }}
find {{ $.Values.shardsvr.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ $.Values.shardsvr.dataNode.containerSecurityContext.runAsUser }}:{{ $.Values.shardsvr.dataNode.podSecurityContext.fsGroup }}
securityContext:
runAsUser: 0
{{- if $.Values.volumePermissions.resources }}
resources: {{ toYaml $.Values.volumePermissions.resources | nindent 12 }}
{{- else if ne $.Values.volumePermissions.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" $.Values.volumePermissions.resourcesPreset) | nindent 12 }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- name: datadir
mountPath: {{ $.Values.shardsvr.persistence.mountPath }}
{{- if $.Values.shardsvr.persistence.subPath }}
subPath: {{ include "common.tplvalues.render" (dict "value" $.Values.shardsvr.persistence.subPath "context" $) }}
{{- end }}
{{- end }}
{{- with $.Values.shardsvr.dataNode.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- include "mongodb-sharded.initContainer.logDir" $ | nindent 8 }}
containers:
- name: mongodb
image: {{ include "mongodb-sharded.image" $ }}
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- if $.Values.shardsvr.dataNode.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.shardsvr.dataNode.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ $.Values.common.containerPorts.mongodb }}
name: mongodb
env:
- name: GLIBC_TUNABLES
value: glibc.pthread.rseq=0
- name: MONGODB_ENABLE_NUMACTL
value: {{ ternary "yes" "no" $.Values.common.mongodbEnableNumactl | quote }}
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or $.Values.image.debug $.Values.diagnosticMode.enabled) | quote }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ $.Values.common.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_INIT_RETRY_ATTEMPTS
value: {{ $.Values.common.mongodbInitRetryAttempts | quote }}
- name: MONGODB_INIT_RETRY_DELAY
value: {{ $.Values.common.mongodbInitRetryDelay | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if $.Values.common.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_PORT_NUMBER
value: {{ $.Values.common.containerPorts.mongodb | quote }}
- name: MONGODB_SHARDING_MODE
value: "shardsvr"
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_MONGOS_HOST
value: {{ include "mongodb-sharded.serviceName" $ }}
- name: MONGODB_MONGOS_PORT_NUMBER
value: {{ $.Values.service.ports.mongodb | quote }}
- name: MONGODB_INITIAL_PRIMARY_HOST
value: {{ printf "%s-shard%d-data-0.%s-headless.%s.svc.%s" (include "common.names.fullname" $ ) $i (include "common.names.fullname" $ ) $.Release.Namespace $.Values.clusterDomain }}
- name: MONGODB_REPLICA_SET_NAME
value: {{ printf "%s-shard-%d" ( include "common.names.fullname" $ ) $i }}
{{- if $.Values.common.useHostnames }}
- name: MONGODB_ADVERTISED_HOSTNAME
value: {{ printf "$(MONGODB_POD_NAME).%s-headless.%s.svc.%s" (include "common.names.fullname" $) (include "common.names.namespace" $) $.Values.clusterDomain }}
{{- end }}
{{- if $.Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ $.Values.auth.rootUser | quote }}
{{- if $.Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
- name: MONGODB_REPLICA_SET_KEY_FILE
value: "/bitnami/mongodb/secrets/mongodb-replica-set-key"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" $ }}
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" $ }}
key: mongodb-replica-set-key
{{- end }}
{{- end }}
- name: MONGODB_ENABLE_IPV6
{{- if $.Values.common.mongodbEnableIPv6 }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if $.Values.common.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if $.Values.shardsvr.dataNode.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS
value: {{ $.Values.shardsvr.dataNode.mongodbExtraFlags | join " " | quote }}
{{- end }}
{{- if $.Values.common.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.dataNode.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if or $.Values.common.extraEnvVarsCM $.Values.common.extraEnvVarsSecret $.Values.shardsvr.dataNode.extraEnvVarsCM $.Values.shardsvr.dataNode.extraEnvVarsSecret }}
envFrom:
{{- if $.Values.common.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if $.Values.common.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.dataNode.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.dataNode.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- end }}
{{- if $.Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
{{- if $.Values.shardsvr.dataNode.command }}
command: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.command "context" $) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.args }}
args: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.args "context" $) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.customLivenessProbe "context" $) | nindent 12 }}
{{- else if $.Values.shardsvr.dataNode.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.shardsvr.dataNode.livenessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- pgrep
- mongod
{{- end }}
{{- if $.Values.shardsvr.dataNode.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.customReadinessProbe "context" $) | nindent 12 }}
{{- else if $.Values.shardsvr.dataNode.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.shardsvr.dataNode.readinessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
{{- end }}
{{- if $.Values.shardsvr.dataNode.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.customStartupProbe "context" $) | nindent 12 }}
{{- else if $.Values.shardsvr.dataNode.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.shardsvr.dataNode.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: mongodb
{{- end }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.dataNode.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/conf
subPath: app-conf-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/tmp
subPath: app-tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/mongodb/logs
subPath: app-logs-dir
- name: empty-dir
mountPath: /.mongodb
subPath: app-mongosh-dir
- name: replicaset-entrypoint-configmap
mountPath: /entrypoint
- name: datadir
mountPath: {{ $.Values.shardsvr.persistence.mountPath }}
{{- if $.Values.shardsvr.persistence.subPath }}
subPath: {{ include "common.tplvalues.render" (dict "value" $.Values.shardsvr.persistence.subPath "context" $) }}
{{- end }}
{{- if or $.Values.shardsvr.dataNode.config $.Values.shardsvr.dataNode.configCM }}
- name: config
mountPath: /bitnami/mongodb/conf/
{{- end }}
{{- if $.Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
{{- if $.Values.common.initScriptsCM }}
- name: custom-init-scripts-cm
mountPath: /docker-entrypoint-initdb.d/cm
{{- end }}
{{- if $.Values.common.initScriptsSecret }}
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/secret
{{- end }}
{{- if $.Values.common.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.dataNode.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.resources }}
resources: {{- toYaml $.Values.shardsvr.dataNode.resources | nindent 12 }}
{{- else if ne $.Values.shardsvr.dataNode.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" $.Values.shardsvr.dataNode.resourcesPreset) | nindent 12 }}
{{- end }}
{{- if $.Values.pmmMetrics.enabled | default false }}
{{- include "mongodb-sharded.pmmClientContainer" $ | nindent 8 }}
{{- end }}
{{- if $.Values.metrics.enabled }}
- name: metrics
image: {{ include "mongodb-sharded.metrics.image" $ }}
imagePullPolicy: {{ $.Values.metrics.image.pullPolicy | quote }}
{{- if $.Values.metrics.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.metrics.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
env:
{{- if $.Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ $.Values.auth.rootUser | quote }}
{{- if $.Values.auth.usePasswordFiles }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" $ }}
key: mongodb-root-password
{{- end }}
{{- end }}
{{- if $.Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
command:
- sh
- -ec
- |-
#!/bin/sh
{{- if $.Values.auth.usePasswordFiles }}
export MONGODB_ROOT_PASSWORD="$(cat "${MONGODB_ROOT_PASSWORD_FILE}")"
{{- end }}
/bin/mongodb_exporter --collect-all --compatible-mode --web.listen-address ":{{ $.Values.metrics.containerPorts.metrics }}" --mongodb.uri mongodb://$(echo $MONGODB_ROOT_USER):$(echo $MONGODB_ROOT_PASSWORD | sed -r "s/@/%40/g;s/:/%3A/g")@localhost:{{ $.Values.common.containerPorts.mongodb }}/admin{{ ternary "?ssl=true" "" $.Values.metrics.useTLS }} {{ $.Values.metrics.extraArgs }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if $.Values.auth.usePasswordFiles }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
ports:
- name: metrics
containerPort: {{ $.Values.metrics.containerPorts.metrics }}
{{- if not $.Values.diagnosticMode.enabled }}
{{- if $.Values.metrics.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
{{- else if $.Values.metrics.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- if $.Values.metrics.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
{{- else if $.Values.metrics.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
httpGet:
path: /metrics
port: metrics
{{- end }}
{{- if $.Values.metrics.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.metrics.customStartupProbe "context" $) | nindent 12 }}
{{- else if $.Values.metrics.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- end }}
{{- if $.Values.metrics.resources }}
resources: {{ toYaml $.Values.metrics.resources | nindent 12 }}
{{- else if ne $.Values.metrics.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" $.Values.metrics.resourcesPreset) | nindent 12 }}
{{- end }}
{{- end }}
{{- with $.Values.shardsvr.dataNode.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
volumes:
- name: empty-dir
emptyDir: {}
- name: replicaset-entrypoint-configmap
configMap:
name: {{ printf "%s-replicaset-entrypoint" (include "common.names.fullname" $) }}
{{- if $.Values.auth.usePasswordFiles }}
- name: secrets
secret:
secretName: {{ include "mongodb-sharded.secret" $ }}
{{- end }}
{{- if $.Values.common.initScriptsCM }}
- name: custom-init-scripts-cm
configMap:
name: {{ include "mongodb-sharded.initScriptsCM" $ }}
defaultMode: 0755
{{- end }}
{{- if $.Values.common.initScriptsSecret }}
- name: custom-init-scripts-secret
secret:
secretName: {{ include "mongodb-sharded.initScriptsSecret" $ }}
defaultMode: 0755
{{- end }}
{{- if or $.Values.shardsvr.dataNode.config $.Values.shardsvr.dataNode.configCM }}
- name: config
configMap:
name: {{ include "mongodb-sharded.shardsvr.dataNode.configCM" $ }}
{{- end }}
{{- if $.Values.common.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.shardsvr.dataNode.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.dataNode.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if not $.Values.shardsvr.persistence.enabled }}
- name: datadir
emptyDir: {}
{{- else }}
{{- if $.Values.shardsvr.persistentVolumeClaimRetentionPolicy.enabled }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ $.Values.shardsvr.persistentVolumeClaimRetentionPolicy.whenDeleted }}
whenScaled: {{ $.Values.shardsvr.persistentVolumeClaimRetentionPolicy.whenScaled }}
{{- end }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: datadir
{{- if or $.Values.shardsvr.persistence.annotations $.Values.commonAnnotations $.Values.shardsvr.persistence.resourcePolicy }}
{{- if or $.Values.commonAnnotations $.Values.shardsvr.persistence.annotations $.Values.shardsvr.persistence.resourcePolicy }}
annotations:
{{- if $.Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 10 }}
{{- end }}
{{- if $.Values.shardsvr.persistence.annotations }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.shardsvr.persistence.annotations "context" $) | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
spec:
accessModes:
{{- range $.Values.shardsvr.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ $.Values.shardsvr.persistence.size | quote }}
{{- with $.Values.shardsvr.persistence.selector }}
selector:
{{- include "common.tplvalues.render" (dict "value" $.Values.shardsvr.persistence.selector "context" (merge $ (dict "Index" $i))) | nindent 10 }}
{{- end }}
{{- include "common.storage.class" (dict "persistence" $.Values.shardsvr.persistence "global" $.Values.global) | nindent 8 }}
{{- end }}
{{- if lt $i (sub $replicas 1) }}
---
{{- end }}
{{- end }}
{{- end }}