mongodb-replicaset

by joaquinito2051

Helm chartv3.9.4App 3.6

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 podDisruptionBudget is 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.

ParameterDescriptionDefault
replicasNumber of replicas in the replica set3
replicaSetNameThe name of the replica setrs0
podDisruptionBudgetPod disruption budget{}
portMongoDB port27017
imagePullSecretsImage pull secrets[]
installImage.repositoryImage name for the install containerunguiculus/mongodb-install
installImage.tagImage tag for the install container0.7
installImage.pullPolicyImage pull policy for the init container that establishes the replica setIfNotPresent
copyConfigImage.repositoryImage name for the copy config init containerbusybox
copyConfigImage.tagImage tag for the copy config init container1.29.3
copyConfigImage.pullPolicyImage pull policy for the copy config init containerIfNotPresent
image.repositoryMongoDB image namemongo
image.tagMongoDB image tag3.6
image.pullPolicyMongoDB image pull policyIfNotPresent
podAnnotationsAnnotations to be added to MongoDB pods{}
securityContext.enabledEnable security contexttrue
securityContext.fsGroupGroup ID for the container999
securityContext.runAsUserUser ID for the container999
securityContext.runAsNonRoottrue
resourcesPod resource requests and limits{}
persistentVolume.enabledIf true, persistent volume claims are createdtrue
persistentVolume.storageClassPersistent volume storage class``
persistentVolume.accessModePersistent volume access modes[ReadWriteOnce]
persistentVolume.sizePersistent volume size10Gi
persistentVolume.annotationsPersistent volume annotations{}
terminationGracePeriodSecondsDuration in seconds the pod needs to terminate gracefully30
tls.enabledEnable MongoDB TLS support including authenticationfalse
tls.cacertThe CA certificate used for the membersOur self signed CA certificate
tls.cakeyThe CA key used for the membersOur key for the self signed CA certificate
init.resourcesPod resource requests and limits (for init containers){}
init.timeoutThe amount of time in seconds to wait for bootstrap to finish900
metrics.enabledEnable Prometheus compatible metrics for pods and replicasetsfalse
metrics.image.repositoryImage name for metrics exporterssalaues/mongodb-exporter
metrics.image.tagImage tag for metrics exporter0.6.1
metrics.image.pullPolicyImage pull policy for metrics exporterIfNotPresent
metrics.portPort for metrics exporter9216
metrics.pathURL Path to expose metics/metrics
metrics.resourcesMetrics pod resource requests and limits{}
metrics.socketTimeoutTime to wait for a non-responding socket3s
metrics.syncTimeoutTime an operation with this session will wait before returning an error1m
metrics.prometheusServiceDiscoveryAdds annotations for Prometheus ServiceDiscoverytrue
auth.enabledIf true, keyfile access control is enabledfalse
auth.keyKey for internal authentication``
auth.existingKeySecretIf set, an existing secret with this name for the key is used``
auth.adminUserMongoDB admin user``
auth.adminPasswordMongoDB admin password``
auth.metricsUserMongoDB clusterMonitor user``
auth.metricsPasswordMongoDB clusterMonitor password``
auth.existingMetricsSecretIf set, and existing secret with this name is used for the metrics user``
auth.existingAdminSecretIf set, and existing secret with this name is used for the admin user``
serviceAnnotationsAnnotations to be added to the service{}
configmapContent of the MongoDB config file``
initMongodStandaloneIf set, initContainer executes script in standalone mode``
nodeSelectorNode labels for pod assignment{}
affinityNode/pod affinities{}
tolerationsList of node taints to tolerate[]
priorityClassNamePod priority class name``
livenessProbe.failureThresholdLiveness probe failure threshold3
livenessProbe.initialDelaySecondsLiveness probe initial delay seconds30
livenessProbe.periodSecondsLiveness probe period seconds10
livenessProbe.successThresholdLiveness probe success threshold1
livenessProbe.timeoutSecondsLiveness probe timeout seconds5
readinessProbe.failureThresholdReadiness probe failure threshold3
readinessProbe.initialDelaySecondsReadiness probe initial delay seconds5
readinessProbe.periodSecondsReadiness probe period seconds10
readinessProbe.successThresholdReadiness probe success threshold1
readinessProbe.timeoutSecondsReadiness probe timeout seconds1
extraVarsSet environment variables for the main container{}
extraLabelsAdditional 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmongodb-replicaset is pinned at v3.9.4 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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