BlogAtlas Vector Search voted most loved vector database in 2024 Retool State of AI reportLearn more >>
MongoDB Developer
Sign in to follow topics
MongoDB Developer Centerchevron-right
Developer Topicschevron-right

Mastering MongoDB Ops Manager on Kubernetes

Arek Borucki7 min read • Published Jan 13, 2023 • Updated Jan 13, 2023
Facebook Icontwitter iconlinkedin icon
Rate this tutorial
This article is part of a three-parts series on deploying MongoDB across multiple Kubernetes clusters using the operators.
Managing MongoDB deployments can be a rigorous task, particularly when working with large numbers of databases and servers. Without the right tools and processes in place, it can be time-consuming to ensure that these deployments are running smoothly and efficiently. One significant issue in managing MongoDB clusters at scale is the lack of automation, which can lead to time-consuming and error-prone tasks such as backups, recovery, and upgrades. These tasks are crucial for maintaining the availability and performance of your clusters.
Additionally, monitoring and alerting can be a challenge, as it may be difficult to identify and resolve issues with your deployments. To address these problems, it's essential to use software that offers monitoring and alerting capabilities. Optimizing the performance of your deployments also requires guidance and support from the right sources.
Finally, it's critical for your deployments to be secure and compliant with industry standards. To achieve this, you need features that can help you determine if your deployments meet these standards.
MongoDB Ops Manager is a web-based application designed to assist with the management and monitoring of MongoDB deployments. It offers a range of features that make it easier to deploy, manage, and monitor MongoDB databases, such as:
  • Automated backups and recovery: Ops Manager can take automated backups of your MongoDB deployments and provide options for recovery in case of failure.
  • Monitoring and alerting: Ops Manager provides monitoring and alerting capabilities to help identify and resolve issues with your MongoDB deployments.
  • Performance optimization: Ops Manager offers tools and recommendations to optimize the performance of your MongoDB deployments.
  • Upgrade management: Ops Manager can help you manage and plan upgrades to your MongoDB deployments, including rolling upgrades and backups to ensure data availability during the upgrade process.
  • Security and compliance: Ops Manager provides features to help you secure your MongoDB deployments and meet compliance requirements.
However, managing Ops Manager can be a challenging task that requires a thorough understanding of its inner workings and how it interacts with the internal MongoDB databases. It is necessary to have the knowledge and expertise to perform upgrades, monitor it, audit it, and ensure its security. As Ops Manager is a crucial part of managing the operation of your MongoDB databases, its proper management is essential.
Fortunately, the MongoDB Enterprise Kubernetes Operator enables us to run Ops Manager on Kubernetes clusters, using native Kubernetes capabilities to manage Ops Manager for us, which makes it more convenient and efficient.

Kubernetes: MongoDBOpsManager custom resource

The MongoDB Enterprise Kubernetes Operator is software that can be used to deploy Ops Manager and MongoDB resources to a Kubernetes cluster, and it's responsible for managing the lifecycle of each of these deployments. It has been developed based on years of experience and expertise, and it's equipped with the necessary knowledge to properly install, upgrade, monitor, manage, and secure MongoDB objects on Kubernetes.
The Kubernetes Operator uses the MongoDBOpsManager custom resource to manage Ops Manager objects. It constantly monitors the specification of the custom resource for any changes and, when changes are detected, the operator validates them and makes the necessary updates to the resources in the Kubernetes cluster.
MongoDBOpsManager custom resources specification defines the following Ops Manager components:
MongoDBOpsManager custom resources specification defines the following Ops Manager components:
the Application Database,
the Ops Manager application, and
the Backup Daemon.
When you use the Kubernetes Operator to create an instance of Ops Manager, the Ops Manager MongoDB Application Database will be deployed as a replica set. It's not possible to configure the Application Database as a standalone database or a sharded cluster.
The Kubernetes Operator automatically sets up Ops Manager to monitor the Application Database that powers the Ops Manager Application. It creates a project named  <ops-manager-deployment-name>-db to allow you to monitor the Application Database deployment. While Ops Manager monitors the Application Database deployment, it does not manage it.
When you deploy Ops Manager, you need to configure it. This typically involves using the configuration wizard. However, you can bypass the configuration wizard if you set certain essential settings in your object specification before deployment. I will demonstrate that in this post.
The Operator automatically enables backup. It deploys a StatefulSet, which consists of a single pod, to host the Backup Daemon Service and creates a Persistent Volume Claim and Persistent Volume for the Backup Daemon's head database. The operator uses the Ops Manager API to enable the Backup Daemon and configure the head database.

Getting started

Alright, let's get started using the operator and build something! For this tutorial, we will need the following tools: 
To get started, we should first create a Kubernetes cluster and then install the MongoDB Kubernetes Operator on the cluster. Part 1 of this series provides instructions on how to do so.
Note For the sake of simplicity, we are deploying Ops Manager in the same namespace as our MongoDB Operator. In a production environment, you should deploy Ops Manager in its own namespace.

Environment pre-checks 

Upon successful creation of a cluster and installation of the operator (described in Part 1), it's essential to validate their readiness for use.
Display our new Kubernetes full cluster name using [kubectx](
You should see your cluster listed here. Make sure your context is set to master cluster.
In order to continue this tutorial, make sure that the operator is in the runningstate.

Using the MongoDBOpsManager CRD

Create a secret containing the username and password on the master Kubernetes cluster for accessing the Ops Manager user interface after installation.

Deploying Ops Manager 

Then, we can deploy Ops Manger on the master Kubernetes cluster with the help of opsmanagers Custom Resource, creating MongoDBOpsManager object, using the following manifest:
After a few minutes, we should see our Ops Manager and Ops Manager MongoDB application database pods running.
Storage part creation has been orchestrated by the operator. Persistent Volumes Claims  are created and can be displayed via
Kubernetes StatefulSets has also been created by the Operator.
The operator has created all required network services, including a Load Balancer service type for the Ops manager access, so we now have an external IP address and can log into the Ops Manager from outside the Kubernetes cluster. You can verify IPs by viewing the services.
The following diagram describes how the Kubernetes Operator reconciles changes to the  MongoDBOpsManager CustomResourceDefinition.
The following diagram describes how the Kubernetes Operator reconciles changes to the MongoDBOpsManager CustomResourceDefinition
To generate Ops Manager URL address, execute:
The URL address will look similar to the example provided, but IP address may vary depending on the Kubernetes cluster.
The final step is to update the Ops Manager Kubernetes manifest to include an external IP address created by Load Balancer in spec.configuration.mms.centralUrl via kubectl patch.
We should wait a few minutes. The Ops Manager pod must be restarted, so wait until the ops-manager-0 pod is in the running state again.
Using the username and password stored in the om-admin-secret ( : p@ssword123), we can log in to the Ops Manager User Interface using the address in the $URL variable.
Enter your username and password and click Login
The Kubernetes Operator was in the Ops Manager ops-manager-db organization and the ops-manager-db project.
Select Ops Manager organization
If we click on the project ops-manager-db, we will be redirected to the panel where we can see the database pods of the Ops Manager application. Ops Manager monitors this database.
Manage your MongoDB cluster from Ops Manager

Basic troubleshooting

If you run through issues during the installation, here are some clues to help you investigate what went wrong.
If you want to display an Ops Manager cluster, use this command. It will show you a general overview of om objects, including internal database and Backup Daemon state.
You can use describe to get a detailed overview.
It's always a good idea to check the Ops Manager logs
or current events from the namespace.


We have just installed Ops Manager on our Kubernetes cluster. This gives us many benefits. The operator has properly installed and configured the Ops Manager instance with the internal database, took care of the storage portion, and created network services, including a Load Balancer. We can now use Ops Manager and easily create any kind of MongoDB database on the Kubernetes cluster following the best practices, monitor instances of our databases, introduce query optimizations with the help of the Ops Manager performance advisor, and provide backup, restore, or rolling upgrades through automation.
In the next part, I will demonstrate how to run the latest type of MongoDB Kubernetes Custom Resource, a Multi Cluster Replica Set. This replica set will be deployed across three separate Kubernetes clusters located in different regions, providing the ideal solution for critical applications that require continuous availability, even in the event of a Kubernetes cluster failure. Want to get started with the MongoDB Ops Manager on your own Kubernetes cluster? Install  it now and see for yourself how it can simplify your operations. Make sure to visit the MongoDB community forum for the latest discussions and resources

Facebook Icontwitter iconlinkedin icon
Rate this tutorial

This is part of a series

Deploying MongoDB Across Multiple Kubernetes Clusters
Up Next

More in this series

Deploying MongoDB Across Multiple Kubernetes Clusters With MongoDBMulti

Sep 05, 2023 | 11 min read

Spark Up Your MongoDB and BigQuery using BigQuery Spark Stored Procedures

Apr 09, 2024 | 5 min read

MongoDB Podcast Interview with Connectors and Translators Team

Sep 23, 2022 | 16 min

How to Get Started with MongoDB Atlas Stream Processing and the HashiCorp Terraform MongoDB Atlas Provider

May 20, 2024 | 5 min read
Table of Contents