mongodb-sharded
Bitnami Helm chart for MongoDB ® Sharded
500K+
MongoDB® is an open source NoSQL database that uses JSON for data storage. MongoDB™ Sharded improves scalability and reliability for large datasets by distributing data across multiple machines.
Disclaimer: The respective trademarks mentioned in the offering are owned by the respective companies. We do not provide a commercial license for any of these products. This listing has an open-source license. MongoDB® is run and maintained by MongoDB, which is a completely separate project from Bitnami.
helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/mongodb-sharded
Note: You need to substitute the placeholders
REGISTRY_NAMEandREPOSITORY_NAMEwith a reference to your Helm chart registry and repository.
This chart bootstraps a MongoDB(®) Sharded deployment on a Kubernetes cluster using the Helm package manager.
Classified as a NoSQL database, MongoDB® eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster.
This chart uses the sharding method for distributing data across multiple machines. This is meant for deployments with very large data sets and high throughput operations.
To install the chart with the release name my-release:
helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/mongodb-sharded
Note: You need to substitute the placeholders
REGISTRY_NAMEandREPOSITORY_NAMEwith a reference to your Helm chart registry and repository. For example, in the case of Bitnami, you need to useREGISTRY_NAME=registry-1.docker.ioandREPOSITORY_NAME=bitnamicharts.
The command deploys MongoDB® on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.
Tip: List all releases using
helm list
This section describes credentials, configuration, and other installation options.
Bitnami charts allow setting resource requests and limits for all containers inside the chart deployment. These are inside the resources value (check parameter table). Setting requests is essential for production workloads and these should be adapted to your specific use case.
To make this process easier, the chart contains the resourcesPreset values, which automatically sets the resources section according to different presets. Check these presets in the bitnami/common chart. However, in production workloads using resourcesPreset is discouraged as it may not fully adapt to your specific needs. Find more information on container resource management in the official Kubernetes documentation.
Bitnami charts configure credentials at first boot. Any further change in the secrets or credentials require manual intervention. Follow these instructions:
kubectl create secret generic SECRET_NAME --from-literal=mongodb-root-password=ROOT_PASSWORD --from-literal=mongodb-replica-set-key=REPLICA_SET_KEY --dry-run -o yaml | kubectl apply -f -
This chart can be integrated with Prometheus by setting metrics.enabled to true. This will deploy a sidecar container with mongodb_exporter in all pods. The pods will have the necessary annotations to be automatically scraped by Prometheus.
It is necessary to have a working installation of Prometheus or Prometheus Operator for the integration to work. Install the Bitnami Prometheus helm chart or the Bitnami Kube Prometheus helm chart to easily have a working Prometheus in your cluster.
The chart can deploy PodMonitor objects for integration with Prometheus Operator installations. To do so, set the value metrics.podMonitor.enabled=true. Ensure that the Prometheus Operator CustomResourceDefinitions are installed in the cluster or it will fail with the following error:
no matches for kind "PodMonitor" in version "monitoring.coreos.com/v1"
Install the Bitnami Kube Prometheus helm chart for having the necessary CRDs and the Prometheus Operator.
It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.
Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.
To modify the MongoDB® version used in this chart you can specify a valid image tag using the image.tag parameter. For example, image.tag=X.Y.Z. This approach is also applicable to other images like exporters.
This chart deploys a sharded cluster by default. Some characteristics of this chart are:
The Bitnami MongoDB® image allows you to use your custom scripts to initialize a fresh instance. You can create a custom config map and give it via initScriptsCM(check options for more details).
The allowed extensions are .sh, and .js.
If you have a need for additional containers to run within the same pod as Kibana (e.g. an additional metrics or logging exporter), you can do so via the sidecars config parameter (available in the mongos, shardsvr.dataNode, shardsvr.arbiter, configsvr and common sections). Simply define your container according to the Kubernetes container spec.
sidecars:
- name: your-image-name
image: your-image
imagePullPolicy: Always
ports:
- name: portname
containerPort: 1234
Similarly, you can add extra init containers using the initContainers parameter.
initContainers:
- name: your-image-name
image: your-image
imagePullPolicy: Always
ports:
- name: portname
containerPort: 1234
In case you want to add extra environment variables (useful for advanced operations like custom init scripts), you can use the extraEnvVars (available in the mongos, shardsvr.dataNode, shardsvr.arbiter, configsvr and common sections) property.
extraEnvVars:
- name: MONGODB_VERSION
value: 4.0
Alternatively, you can use a ConfigMap or a Secret with the environment variables. To do so, use the extraEnvVarsCM or the extraEnvVarsSecret values.
It is possible to not deploy any shards or a config server. For example, it is possible to simply deploy mongos instances that point to an external MongoDB® sharded database. If that is the case, set the configsvr.external.host and configsvr.external.replicasetName for the mongos instances to connect. For authentication, set the configsvr.external.rootPassword and configsvr.external.replicasetKey values.
This chart allows you to set your custom affinity using the XXX.affinity parameter(s). Find more information about Pod's affinity in the kubernetes documentation.
As an alternative, you can use of the preset configurations for pod affinity, pod anti-affinity, and node affinity available at the bitnami/common chart. To do so, set the XXX.podAffinityPreset, XXX.podAntiAffinityPreset, or XXX.nodeAffinityPreset parameters.
To back up and restore Helm chart deployments on Kubernetes, you need to back up the persistent volumes from the source deployment and attach them to a new deployment using Velero, a Kubernetes backup/restore tool. Find the instructions for using Velero in this guide.
The FIPS parameters only have effect if you are using images from the Bitnami Secure Images catalog.
For more information on this new support, please refer to the FIPS Compliance section.
This chart includes an optional MCP (Model Context Protocol) component that provides a standardized interface for AI assistants and LLMs to interact with MongoDB. When enabled, it deploys a separate service that exposes MongoDB functionality through the MCP protocol. The upstream project is available at mongodb-js/mongodb-mcp. To enable the MCP component, set mcp.enabled=true:
By default (mcp.useRootCredentials=true), the MCP component automatically connects to the MongoDB Sharded cluster via the mongos service using the root credentials. The connection string is passed via the --connectionString argument and points to the mongos router, which is the correct entry point for sharded clusters.
When auth.rootPasswordFilesEnabled=true, the MCP container uses a bash script to read credentials from mounted secret files and then executes the MCP server with exec. This ensures proper signal handling and process management.
When auth.rootPasswordFilesEnabled=false, credentials are passed as environment variables:
MONGODB_USERNAME: Set to the MongoDB root usernameMONGODB_PASSWORD: Retrieved from the MongoDB root password secretMONGODB_DATABASE: Set to "admin" databaseIf you want to use custom MongoDB credentials instead, set mcp.useRootCredentials=false and provide your own credentials:
mcp:
enabled: true
useRootCredentials: false
extraEnvVars:
- name: MONGODB_USERNAME
value: my-custom-user
- name: MONGODB_PASSWORD
valueFrom:
secretKeyRef:
name: my-mongodb-credentials
key: password
- name: MONGODB_DATABASE
value: mydb
- name: MONGODB_CONNECTION_STRING
value: mongodb://my-custom-user:password@mongodb-sharded-service:27017/mydb
The MCP server listens on port 8000 by default and uses HTTP as the transport protocol. By default, the server runs in read-only mode (mcp.readOnly=true), which prevents any write operations to the database.
For enhanced security, you can enable authentication and authorization using a kube-rbac-proxy sidecar:
mcp:
enabled: true
auth:
enabled: true
allowedServiceAccounts:
- namespace: default
name: my-ai-assistant
- namespace: ai-namespace
name: another-service
When mcp.auth.enabled is set to true:
mcp.auth.allowedServiceAccounts can access the endpointThis provides Kubernetes-native authentication and authorization, ensuring that only authorized service accounts can interact with the MCP MongoDB server.
When authentication is enabled, TLS is always enabled and automatically configured for the kube-rbac-proxy sidecar. By default, the chart will auto-generate a self-signed certificate using Helm capabilities:
mcp:
enabled: true
auth:
enabled: true
tls:
autoGenerated:
enabled: true
engine: helm # or cert-manager
You can also provide your own TLS certificate:
mcp:
enabled: true
auth:
enabled: true
tls:
autoGenerated:
enabled: false
existingSecret: my-tls-secret
Or provide the certificate directly:
mcp:
enabled: true
auth:
enabled: true
tls:
autoGenerated:
enabled: false
cert: |-
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
key: |-
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
The Bitnami MongoDB® image stores the MongoDB® data and configurations at the /bitnami/mongodb path of the container.
The chart mounts a Persistent Volume at this location. The volume is created using dynamic volume provisioning.
As the image run as non-root by default, it is necessary to adjust the ownership of the persistent volume so that the container can write data into it.
By default, the chart is configured to use Kubernetes Security Context to automatically change the ownership of the volume. However, this feature does not work in all Kubernetes distributions. As an alternative, this chart supports using an initContainer to change the ownership of the volume before mounting it in the final destination.
You can enable this initContainer by setting volumePermissions.enabled to true.
The Bitnami Kibana chart supports mounting extra volumes (either PVCs, secrets or configmaps) by using the extraVolumes and extraVolumeMounts properties (available in the mongos, shardsvr.dataNode, shardsvr.arbiter, configsvr and common sections). This can be combined with advanced operations like adding extra init containers and sidecars.
The following subsections list global, common, and component-specific parameters.
| Name | Description | Value |
|---|---|---|
global.imageRegistry | Global Docker image registry | "" |
global.imagePullSecrets | Global Docker registry secret names as an array | [] |
global.defaultStorageClass | Global default StorageClass for Persistent Volume(s) | "" |
global.storageClass | DEPRECATED: use global.defaultStorageClass instead | "" |
global.defaultFips | Default value for the FIPS configuration (allowed values: '', restricted, relaxed, off). Can be overridden by the 'fips' object | restricted |
global.security.allowInsecureImages | Allows skipping image verification | false |
global.compatibility.openshift.adaptSecurityContext | Adapt the securityContext sections of the deployment to make them compatible with Openshift restricted-v2 SCC: remove runAsUser, runAsGroup and fsGroup and let the platform use their allowed default IDs. Possible values: auto (apply if the detected running cluster is Openshift), force (perform the adaptation always), disabled (do not perform adaptation) | auto |
| Name | Description | Value |
|---|---|---|
kubeVersion | Override Kubernetes version | "" |
nameOverride | String to partially override common.names.name | "" |
fullnameOverride | String to fully override common.names.fullname | "" |
namespaceOverride | String to fully override common.names.namespace | "" |
commonLabels | Labels to add to all deployed objects | {} |
commonAnnotations | Annotations to add to all deployed objects | {} |
clusterDomain | Kubernetes cluster domain name | cluster.local |
extraDeploy | Array of extra objects to deploy with the release | [] |
diagnosticMode.enabled | Enable diagnostic mode (all probes will be disabled and the command will be overridden) | false |
diagnosticMode.command | Command to override all containers in the deployment | ["sleep"] |
diagnosticMode.args | Args to override all containers in the deployment | ["infinity"] |
| Name | Description | Value |
|---|---|---|
image.registry | MongoDB(®) Sharded image registry | REGISTRY_NAME |
image.repository | MongoDB(®) Sharded Image name | REPOSITORY_NAME/mongodb-sharded |
image.digest | MongoDB(®) Sharded image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag | "" |
image.pullPolicy | MongoDB(®) Sharded image pull policy | IfNotPresent |
image.pullSecrets | Specify docker- |
Note: the README for this chart is longer than the DockerHub length limit of 25000, so it has been trimmed. The full README can be found at https://techdocs.broadcom.com/us/en/vmware-tanzu/bitnami-secure-images/bitnami-secure-images/services/bsi-app-doc/apps-charts-mongodb-sharded-index.html
Content type
Image
Digest
sha256:dd407ff59…
Size
7.8 kB
Last updated
11 months ago
docker pull bitnamicharts/mongodb-sharded:sha256-260fc5ace99b20b2d4a49f178041ec16145aa32c042b25a3b5eb527a46720146Pulls:
2,469
Last week