For the complete documentation index, see llms.txt. This page is also available as Markdown.

Use an external self-managed MongoDB with your installation

Learn how to use an external self-managed MongoDB with Self-Managed Enterprise Edition installations.

Harness Self-Managed Enterprise Edition requires you to install a database by default. You can optionally use an external self-managed database with your installation. This enables you to separate your data from node execution. To use an external self-managed MongoDB with your Harness Self-Managed Enterprise Edition installation, you must ensure that your hardware, software, and network meet the minimum requirements for installation and configuration. This tutorial describes how to deploy MongoDB with VMs and replication.

Limitations

MongoDB VMs offer many advantages, but there are a few limitations to consider:

  • Resource overhead: Running a VM incurs resource overhead, such as CPU and memory usage, which may impact the performance of the MongoDB database.

  • Hardware dependency: VM performance is influenced by the underlying hardware. Ensure that the host system provides sufficient resources for the VM to function optimally.

  • Complexity: Setting up and managing a VM requires knowledge and expertise in virtualization technologies.

  • Maintenance overhead: VMs require regular maintenance, including updates, backups, and monitoring, which adds overhead compared to a native MongoDB installation.

Hardware requirements

Harness recommends a MongoDB three member replica set configuration with the following minimum hardware:

  • Three nodes

  • Four CPU (3*4 = 12 CPU)

  • 8GB RAM (3*8 = 24GB RAM)

  • 300GB SSD data storage, depending on your requirements

Software requirements

External database setup requires the following software:

  • Supported OS: Ubuntu 20.04

Network requirements

Ensure the following:

  • Set allowlisting of VMs so each VM can send traffic. Add the source using MongoDB, for example, the Kubernetes cluster service range to your allowlist.

  • Reserve internal and external static addresses for each VM.

Architecture

MongoDB architecture

MongoDB replica set configuration without region failover (single data center)

This architecture supports HA for databases. It does not support region/DR failover.

MongoDB architecture 1

MongoDB replica set configuration with region failover setup (two data centers)

This architecture supports the following:

  • HA for databases

  • Region (DR) failover

The DC1 MongoDB priority level should be higher than DC2 to prevent cross-network DB connections.

DR architecture 1

MongoDB replica set configuration with region failover setup (3 data centers)

This architecture supports the following:

  • HA for databases

  • Region (DR) failover

The DC1 and DC2 MongoDB priority levels should be higher than DC3 to prevent cross-network DB connections.

DR architecture 2

Set up MongoDB VMs

To set up a MongoDB VM, do the following:

  1. Connect to the VM and make sure you are running as root to prevent permission issues.

  2. Create your VM terminal, connect to the terminal, and log in as root.

  3. Run the following to update packages.

  4. Import the public key used by the package management system.

  5. Add the Mongo third party repository.

    Debian:

    Ubuntu 21.10 and later:

  6. Run the following command to issue a MongoDB public GPG key.

  7. Run the following to update the key.

  8. Run the following to install MongoDB.

  9. Run the following to start MongoDB.

  10. Verify that MongoDB started successfully.

  11. Stop the MongoDB instance.

  12. Modify the mongod.conf configuration file.

  13. Locate the replication section, and uncomment the replSetName and bindIp lines. Configure them as follows:

  14. Complete the steps above for all three VMs.

  15. Log in to one VM and run following commands.

  16. Log in to the remaining two VMs, and run following commands.

  17. Log in to your MongoDB primary instance using the mongo command, and run following command to create your replica set.

    To identify primary node, run this command:

  18. Log in to your primary MongoDB, and run the following command.

  19. Run the following to verify your replica set configuration.

  20. Restart MongoDB on all your VMs.

  21. Check all your replicas for errors.

  22. Log in to your Kubernetes cluster, and create a mongo-secret.yaml file.

  23. Update the file with your MongoDB-specific override changes.

  24. Run Helm install.

Last updated

Was this helpful?