mongodb-replicaset
NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications.
About this chart
MongoDB Helm Chart
Prerequisites Details
- Kubernetes 1.9+
- Kubernetes beta APIs enabled only if
podDisruptionBudgetis enabled - PV support on the underlying infrastructure
StatefulSet Details
- https://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/
StatefulSet Caveats
- https://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/#limitations
Chart Details
This chart implements a dynamically scalable MongoDB replica set using Kubernetes StatefulSets and Init Containers.
Installing the Chart
To install the chart with the release name my-release:
helm install --name my-release <helm-repo>/mongodb-replicaset
helm install --name my-release stable/mongodb-replicaset
Configuration
The following table lists the configurable parameters of the mongodb chart and their default values.
| Parameter | Description | Default |
|---|---|---|
replicas | Number of replicas in the replica set | 3 |
replicaSetName | The name of the replica set | rs0 |
podDisruptionBudget | Pod disruption budget | {} |
port | MongoDB port | 27017 |
imagePullSecrets | Image pull secrets | [] |
installImage.repository | Image name for the install container | unguiculus/mongodb-install |
installImage.tag | Image tag for the install container | 0.7 |
installImage.pullPolicy | Image pull policy for the init container that establishes the replica set | IfNotPresent |
copyConfigImage.repository | Image name for the copy config init container | busybox |
copyConfigImage.tag | Image tag for the copy config init container | 1.29.3 |
copyConfigImage.pullPolicy | Image pull policy for the copy config init container | IfNotPresent |
image.repository | MongoDB image name | mongo |
image.tag | MongoDB image tag | 3.6 |
image.pullPolicy | MongoDB image pull policy | IfNotPresent |
podAnnotations | Annotations to be added to MongoDB pods | {} |
securityContext.enabled | Enable security context | true |
securityContext.fsGroup | Group ID for the container | 999 |
securityContext.runAsUser | User ID for the container | 999 |
securityContext.runAsNonRoot | true | |
resources | Pod resource requests and limits | {} |
persistentVolume.enabled | If true, persistent volume claims are created | true |
persistentVolume.storageClass | Persistent volume storage class | `` |
persistentVolume.accessMode | Persistent volume access modes | [ReadWriteOnce] |
persistentVolume.size | Persistent volume size | 10Gi |
persistentVolume.annotations | Persistent volume annotations | {} |
terminationGracePeriodSeconds | Duration in seconds the pod needs to terminate gracefully | 30 |
tls.enabled | Enable MongoDB TLS support including authentication | false |
tls.cacert | The CA certificate used for the members | Our self signed CA certificate |
tls.cakey | The CA key used for the members | Our key for the self signed CA certificate |
init.resources | Pod resource requests and limits (for init containers) | {} |
init.timeout | The amount of time in seconds to wait for bootstrap to finish | 900 |
metrics.enabled | Enable Prometheus compatible metrics for pods and replicasets | false |
metrics.image.repository | Image name for metrics exporter | ssalaues/mongodb-exporter |
metrics.image.tag | Image tag for metrics exporter | 0.6.1 |
metrics.image.pullPolicy | Image pull policy for metrics exporter | IfNotPresent |
metrics.port | Port for metrics exporter | 9216 |
metrics.path | URL Path to expose metics | /metrics |
metrics.resources | Metrics pod resource requests and limits | {} |
metrics.socketTimeout | Time to wait for a non-responding socket | 3s |
metrics.syncTimeout | Time an operation with this session will wait before returning an error | 1m |
metrics.prometheusServiceDiscovery | Adds annotations for Prometheus ServiceDiscovery | true |
auth.enabled | If true, keyfile access control is enabled | false |
auth.key | Key for internal authentication | `` |
auth.existingKeySecret | If set, an existing secret with this name for the key is used | `` |
auth.adminUser | MongoDB admin user | `` |
auth.adminPassword | MongoDB admin password | `` |
auth.metricsUser | MongoDB clusterMonitor user | `` |
auth.metricsPassword | MongoDB clusterMonitor password | `` |
auth.existingMetricsSecret | If set, and existing secret with this name is used for the metrics user | `` |
auth.existingAdminSecret | If set, and existing secret with this name is used for the admin user | `` |
serviceAnnotations | Annotations to be added to the service | {} |
configmap | Content of the MongoDB config file | `` |
initMongodStandalone | If set, initContainer executes script in standalone mode | `` |
nodeSelector | Node labels for pod assignment | {} |
affinity | Node/pod affinities | {} |
tolerations | List of node taints to tolerate | [] |
priorityClassName | Pod priority class name | `` |
livenessProbe.failureThreshold | Liveness probe failure threshold | 3 |
livenessProbe.initialDelaySeconds | Liveness probe initial delay seconds | 30 |
livenessProbe.periodSeconds | Liveness probe period seconds | 10 |
livenessProbe.successThreshold | Liveness probe success threshold | 1 |
livenessProbe.timeoutSeconds | Liveness probe timeout seconds | 5 |
readinessProbe.failureThreshold | Readiness probe failure threshold | 3 |
readinessProbe.initialDelaySeconds | Readiness probe initial delay seconds | 5 |
readinessProbe.periodSeconds | Readiness probe period seconds | 10 |
readinessProbe.successThreshold | Readiness probe success threshold | 1 |
readinessProbe.timeoutSeconds | Readiness probe timeout seconds | 1 |
extraVars | Set environment variables for the main container | {} |
extraLabels | Additional labels to add to resources | {} |
MongoDB config file
All options that depended on the chart configuration are supplied as command-line arguments to mongod. By default, the chart creates an empty config file. Entries may be added via the configmap configuration value.
Specify each parameter using the --set key=value[,key=value] argument to helm install.
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
Specify each parameter using the --set key=value[,key=value] argument to helm install.
helm install --name my-release -f values.yaml <helm-repo>/mongodb-replicaset
helm install --name my-release -f values.yaml stable/mongodb-replicaset
Tip: You can use the default values.yaml
Once you have all 3 nodes in running, you can run the "test.sh" script in this directory, which will insert a key into the primary and check the secondaries for output. This script requires that the `$REL
Deploy mongodb-replicaset with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mongodb-replicaset 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-replicaset is pinned at v3.9.4 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