kubernetesmongodb

Understand architecture options

Improve this page by contributing to our documentation.

This chart allows installing MongoDB® using two different architecture setups: standalone or replicaset. Use the architecture parameter to choose the one to use, as architecture=“standalone” or architecture=“replicaset”.

Standalone architecture

The standalone architecture installs a deployment (or StatefulSet) with one MongoDB® server (it cannot be scaled):

 ----------------
|   MongoDB® |
|      svc       |
 ----------------
        |
        v
   ------------
  |MongoDB®|
  |   Server   |
  |    Pod     |
   -----------

Replicaset architecture

The chart also supports the replicaset architecture with and without a MongoDB® Arbiter:

When the MongoDB® Arbiter is enabled, the chart installs two StatefulSets: A StatefulSet with N MongoDB® servers (organised with one primary and N-1 secondary nodes), and a StatefulSet with one MongoDB® arbiter node (it cannot be scaled).

 ----------------   ----------------   ----------------      -------------
| MongoDB® 0 | | MongoDB® 1 | | MongoDB® N |    |   Arbiter   |
|  external svc  | |  external svc  | |  external svc  |    |     svc     |
 ----------------   ----------------   ----------------      -------------
        |                  |                  |                    |
        v                  v                  v                    v
 ----------------   ----------------   ----------------      --------------
| MongoDB® 0 | | MongoDB® 1 | | MongoDB® N |    | MongoDB® |
|    Server      | |     Server     | |     Server     |    |    Arbiter   |
|     Pod        | |      Pod       | |      Pod       |    |     Pod      |
 ----------------   ----------------   ----------------      --------------
      primary           secondary         secondary

The PSA model is useful when the third Availability Zone cannot hold a full MongoDB® instance. The MongoDB® Arbiter as decision maker is lightweight and can run alongside other workloads.

NOTE: An update takes your MongoDB® replicaset offline if the Arbiter is enabled and the number of MongoDB® replicas is two. Helm applies updates to the StatefulSets for the MongoDB® instance and the Arbiter at the same time so you lose two out of three quorum votes.

Without the Arbiter, the chart deploys a single statefulset with N MongoDB® servers (organised with one primary and N-1 secondary nodes).

 ----------------   ----------------   ----------------
| MongoDB® 0 | | MongoDB® 1 | | MongoDB® N |
|  external svc  | |  external svc  | |  external svc  |
 ----------------   ----------------   ----------------
        |                  |                  |
        v                  v                  v
 ----------------   ----------------   ----------------
| MongoDB® 0 | | MongoDB® 1 | | MongoDB® N |
|    Server      | |     Server     | |     Server     |
|     Pod        | |      Pod       | |      Pod       |
 ----------------   ----------------   ----------------
      primary           secondary         secondary

There are no services load balancing requests between MongoDB® nodes; instead, each node has an associated service to access them individually.

NOTE: Although the first replica is initially assigned the primary role, any of the secondary nodes can become the primary if it is down, or during upgrades. Do not make any assumption about what replica has the primary role. Instead, configure your MongoDB® client with the list of MongoDB® hostnames so it can dynamically choose the node to send requests.