mongodb
by CloudPirates
MongoDB a flexible NoSQL database for scalable, real-time data management
About this chart
MongoDB
A flexible NoSQL database for scalable, real-time data management.
Description
This Helm chart provides a complete MongoDB StatefulSet deployment solution with persistent storage, authentication, health checks, and security configurations. It uses the official mongo Docker image and supports various deployment scenarios from development to production environments.
Features
- Official MongoDB Image: Uses the official
mongoDocker image from Docker Hub - Authentication: Configurable MongoDB authentication with root user credentials
- Custom User: Optional custom user creation at initialisation with configurable credentials and database — works in both standalone and sharded cluster modes
- Persistent Storage: Automatic persistent volume management through StatefulSet volumeClaimTemplates
- Security: Non-root container execution with proper security contexts
- Health Checks: Liveness and readiness probes using mongosh
- Flexible Configuration: Comprehensive configuration options for various deployment needs
- Service Account: RBAC-ready with configurable service account
- Resource Management: Configurable CPU and memory limits/requests
- Sharded Cluster: Full sharded cluster support with config servers, mongos routers, and shard servers including automated initialisation, replica set setup, balancer configuration, and auto-sharding
Installing the Chart
To install the chart with the release name my-mongodb:
helm install my-mongodb oci://registry-1.docker.io/cloudpirates/mongodb
To install with custom values:
helm install my-mongodb oci://registry-1.docker.io/cloudpirates/mongodb -f my-values.yaml
Uninstalling the Chart
To uninstall/delete the my-mongodb deployment:
helm delete my-mongodb
Security & Signature Verification
This Helm chart is cryptographically signed with Cosign to ensure authenticity and prevent tampering.
Public Key:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5U+rM2d3hDjgP5T3cLShuuQIU9vR
Z4/G+Nug6q5vRa+C3qUA1wXjbaJFAfcIrv5VjmYAYOj13shnPpp3Zh4fnQ==
-----END PUBLIC KEY-----
To verify the helm chart before installation, copy the public key to the file cosign.pub and run cosign:
cosign verify --key cosign.pub registry-1.docker.io/cloudpirates/mongodb:<version>
Configuration
The following table lists the configurable parameters of the MongoDB chart and their default values.
Global Parameters
| Parameter | Description | Default |
|---|---|---|
global.imageRegistry | Global Docker Image registry | "" |
global.imagePullSecrets | Global Docker registry secret names as an array | [] |
global.dataNodes.extraContainers | Additional containers to add to all data node pods (statefulset, statefulset-shard, statefulset-hidden, statefulset-configserver) | [] |
global.dataNodes.extraVolumes | Additional volumes to add to all data node pods (statefulset, statefulset-shard, statefulset-hidden, statefulset-configserver) | [] |
Common Parameters
| Parameter | Description | Default |
|---|---|---|
nameOverride | String to partially override mongodb.fullname | "" |
fullnameOverride | String to fully override mongodb.fullname | "" |
namespaceOverride | String to override the namespace for all resources | "" |
commonLabels | Labels to add to all deployed objects | {} |
commonAnnotations | Annotations to add to all deployed objects | {} |
podAnnotations | Annotations to add to the pod created by the statefulset | {} |
podLabels | Labels to add to the pod created by the statefulset | {} |
revisionHistoryLimit | Maximum number of revisions maintained in revision history | 10 |
podManagementPolicy | Pod management policy | OrderedReady |
updateStrategyType | Pod update strategy | RollingUpdate |
MongoDB Image Parameters
| Parameter | Description | Default |
|---|---|---|
image.registry | MongoDB image registry | docker.io |
image.repository | MongoDB image repository | mongo |
image.tag | MongoDB image tag | "8.2.1@sha256:86835e8da0f94efd61334decb320fa43e8a60027688cbd856bf29d065b470338" |
image.pullPolicy | MongoDB image pull policy | Always |
image.extraArgs | Override default container args (useful when using custom images) | [] |
Replica Configuration
| Parameter | Description | Default |
|---|---|---|
replicaCount | Number of MongoDB replicas to deploy | 1 |
Service Parameters
| Parameter | Description | Default |
|---|---|---|
service.type | Kubernetes service type | ClusterIP |
service.port | MongoDB service port | 27017 |
service.annotations | Annotations to add to the mongodb service | {} |
service.headlessServiceSuffix | headless |
MongoDB Authentication Parameters
| Parameter | Description | Default |
|---|---|---|
auth.enabled | Enable MongoDB authentication | true |
auth.rootUsername | MongoDB root username | admin |
auth.rootPassword | MongoDB root password (if empty, random password will be generated) | "" |
auth.existingSecret | Name of existing secret containing MongoDB password | "" |
auth.existingSecretPasswordKey | Key in existing secret containing MongoDB password | "" |
MongoDB Configuration Parameters
| Parameter | Description | Default |
|---|---|---|
config.mountPath | MongoDB configuration options | /etc/mongo |
config.content | Include your custom MongoDB configurations here as string | systemLog:\n quiet: true\n verbosity: 0\nnet:\n bindIpAll: true |
config.existingConfigmap | Name of an existing Configmap to use instead of creating one | "" |
config.existingConfigmapKey | Name of the key in the Configmap that should be used | "" |
Custom Role Configuration
Custom MongoDB roles can be created at initialisation time via the customRoles array. Roles are created before custom users, so you can reference custom roles in customUsers[].roles. If a role already exists, it will be skipped (not updated).
This works in standalone, replica set, and sharded cluster modes.
| Parameter | Description | Default |
|---|---|---|
customRoles[].role | Role name to create (required) | |
customRoles[].database | Database where the role is created | admin |
customRoles[].privileges | List of privilege objects with resource and actions | [] |
customRoles[].privileges[].resource | MongoDB resource document (e.g. { db: "", collection: "" } or { cluster: true }) | |
customRoles[].privileges[].actions | List of MongoDB privilege actions (e.g. ["find", "insert"]) | |
customRoles[].roles | Inherited roles. Strings apply to the same database; use { role, db } for cross-database inheritance | [] |
Example:
customRoles:
- role: myCustomRole
database: admin
privileges:
- resource: { cluster: true }
actions: ["find"]
- resource: { db: "", collection: "" }
actions: ["find", "listCollections", "listIndexes"]
roles:
- backup
- restore
- clusterMonitor
- { role: "read", db: "reporting" }
Custom User Configuration
Multiple users can be created at initialisation time via the customUsers array. Each user gets the specified roles on their database. This works in standalone, replica set, and sharded cluster modes (in sharded mode users are created via the mongos router after cluster initialisation).
Each entry supports either inline credentials (name + optional password/database) or an existing Kubernetes secret (existingSecret).
| Parameter | Description | Default |
|---|---|---|
customUsers[].name | Username. A secret named <release>-custom-user-<i>-secret is auto-generated when no existingSecret | "" |
customUsers[].database | Database to create the user in. Defaults to name if not set | "" |
customUsers[].password | Password. A random 32-char password is generated if not set | "" |
customUsers[].existingSecret | Name of an existing secret. Supports Helm template strings | "" |
customUsers[].secretKeys.name | Key in existingSecret holding the username | CUSTOM_USER |
customUsers[].secretKeys.password | Key in existingSecret holding the password | CUSTOM_PASSWORD |
customUsers[].secretKeys.database | Key in existingSecret holding the database name | CUSTOM_DB |
customUsers[].roles | MongoDB roles to grant. Plain strings apply to the user's own database; use {role, db} for cross-database roles | [readWrite, dbAdmin] |
Examples:
customUsers:
- name: appuser
database: appdb
password: supersecret
roles:
- readWrite
- dbAdmin
- name: readonlyuser
database: reportingdb
roles:
- read
# Cross-database role
- name: monitoruser
database: admin
roles:
- clusterMonitor
- { role: readAnyDatabase, db: admin }
# From an existing secret
- existingSecret: my-app-credentials
secretKeys:
name: MONGO_USERNAME
password: MONGO_PASSWORD
database: MONGO_DATABASE
roles:
- readWrite
Persistence Parameters
| Parameter | Description | Default |
Deploy mongodb with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mongodb on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartmongodb is pinned at v0.20.6 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply