MongoDB

tutorial

The Mender server uses MongoDB as primary storage layer. It doesn't have any particular requirements about the setup of the database, and can use MongoDB both in a single node setup and as a replica set.

To install MongoDB on the Kubernetes cluster using the Helm chart, for example deploying a replica set with two members and an arbitrer using Helm, run:

On the Debian family of distributions you can install pwgen with apt-get install pwgen. On the RPM family of distributions, you can install it with yum install pwgen.

export MONGODB_ROOT_PASSWORD=$(pwgen 32 1)
export MONGODB_REPLICA_SET_KEY=$(pwgen 32 1)

cat >mongodb.yml <<EOF
architecture: "replicaset"
replicaCount: 2
arbiter:
  enabled: true
auth:
  rootPassword: ${MONGODB_ROOT_PASSWORD}
  replicaSetKey: ${MONGODB_REPLICA_SET_KEY}
image:
  tag: "4.4.6-debian-10-r29"
persistence:
  size: "8Gi"
EOF

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm upgrade --install mongodb bitnami/mongodb --version 10.21.1 -f mongodb.yml

You can get the connection string to connect to your mongodb cluster running:

echo mongodb://root:${MONGODB_ROOT_PASSWORD}@mongodb-0.mongodb-headless.default.svc.cluster.local:27017,mongodb-1.mongodb-headless.default.svc.cluster.local:27017
mongodb://root:<random-password>@mongodb-0.mongodb-headless.default.svc.cluster.local:27017,mongodb-1.mongodb-headless.default.svc.cluster.local:27017

Please refer to the MongoDB official documentation for further information about setting up a production-grade MongoDB cluster.

We welcome contributions to improve this documentation. To submit a change, use the Edit link at the top of the page or email us at .