Deploying the MongoDB Enterprise Kubernetes Operator on Google Cloud
Rate this tutorial
This article is part of a three-parts series on deploying MongoDB across multiple Kubernetes clusters using the operators.
Deploying and managing MongoDB on Kubernetes can be a daunting task. It requires creating and configuring various Kubernetes resources, such as persistent volumes, services, and deployments, which can be time-consuming and require a deep understanding of both Kubernetes and MongoDB products. Furthermore, tasks such as scaling, backups, and upgrades must be handled manually, which can be complex and error-prone. This can impact the reliability and availability of your MongoDB deployment and may require frequent manual intervention to keep it running smoothly. Additionally, it can be hard to ensure that your MongoDB deployment is running in the desired state and is able to recover automatically from failures.
Fortunately, MongoDB offers operators, which are software extensions to the Kubernetes API that use custom resources to manage applications and their components. The MongoDB Operator translates human knowledge of creating a MongoDB instance into a scalable, repeatable, and standardized method, and leverages Kubernetes features to operate MongoDB for you. This makes it easier to deploy and manage MongoDB on Kubernetes, providing advanced features and functionality for running MongoDB in cloud-native environments.
There are three main Kubernetes operators available for deploying and managing MongoDB smoothly and efficiently in Kubernetes environments:
- is an open-source operator that is available for free and can be used to deploy and manage MongoDB Replica Set on any Kubernetes cluster. It provides basic functionality for deploying and managing MongoDB but does not include some of the more advanced features available in the Enterprise and Atlas operators.
- is a commercial Kubernetes operator included with the MongoDB Enterprise subscription. It allows you to easily deploy and manage any type of MongoDB deployment (standalone, replica set, sharded cluster) on Kubernetes, providing advanced features and functionality for deploying and managing MongoDB in cloud-native environments.
- is an operator that is available as part of the Atlas service. It allows you to quickly deploy and manage MongoDB on the Atlas cloud platform, providing features such as automatic provisioning and scaling of MongoDB clusters, integration with Atlas features and services, and automatic backups and restores. You can learn more about this operator in our blog post on .
This article will focus on the Enterprise Operator. seamlessly integrates with other MongoDB Enterprise features and services, such as MongoDB Ops Manager (which can also run on Kubernetes) and MongoDB Cloud Manager. This allows you to easily monitor, back up, upgrade, and manage your MongoDB deployments from a single, centralized location, and provides access to a range of tools and services for managing, securing, and optimizing your deployment.
The MongoDB Enterprise automates the process of creating and managing MongoDB instances in a scalable, repeatable, and standardized manner. It uses the Kubernetes API and tools to handle the lifecycle events of a MongoDB cluster, including provisioning storage and computing resources, configuring network connections, setting up users, and making changes to these settings as needed. This helps to ease the burden of manually configuring and managing stateful applications, such as databases, within the Kubernetes environment.
(Custom Resource Definitions) is a feature in Kubernetes that allows users to create and manage custom resources in their Kubernetes clusters. are extensions of the Kubernetes API that allow users to define their own object types and associated behaviors. With CRDs, you can create custom resources that behave like built-in Kubernetes resources, such as StatefulSets, Deployments, Pods, and Services, and manage them using the same tools and interfaces. This allows you to extend the functionality of Kubernetes and tailor it to their specific needs and requirements.
The MongoDB Enterprise Operator currently provides the following custom resources for deploying MongoDB on Kubernetes:
For this tutorial, we will need the following tools:
Now that the cluster has been created, we need to obtain the credentials.
Display the newly created cluster.
You should see your cluster listed here. Make sure your context is set to master cluster.
We are able to start MongoDB Kubernetes Operator installation on our newly created Kubernetes cluster!
I want to create the operator in a separate, dedicated Kubernetes namespace (the operator uses
default namespace by default). This will allow me to isolate the operator and any resources it creates from other resources in my cluster. The following command will install the CRDs and the Enterprise Operator in the
mongodb-operatornamespace. The operator will be watching only the
mongodb-operator namespace. You can read more about in the official MongoDB documentation.
Start by creating the
Install the MongoDB Kubernetes Operator and set it to watch only the
The namespace has been created and the operator is running! You can see this by listing the pods in the newly created namespace.
You can see that the helm chart is running with this command.
You can verify that the installation was successful and is currently running with the following command.
Let's display Custom Resource Definitions installed in the step above in the watched namespace.
All required service accounts has been created in watched namespace.
Validate if the Kubernetes Operator was installed correctly by running the following command and verify the output.
Finally, double-check watched namespaces.
The MongoDB Enterprise Operator is now running in your GKE cluster.
It's worth mentioning another operator here --- a new service that integrates Atlas resources with your Kubernetes cluster. Atlas can be deployed in multi-cloud environments including Google Cloud. The Atlas Kubernetes Operator allows you to deploy and manage cloud-native applications that require data services in a single control plane with secure enterprise platform integration.
This operator is responsible for managing resources in Atlas using Kubernetes custom resources, ensuring that the configurations of projects, database deployments, and database users in Atlas are consistent with each other. The Atlas Kubernetes Operator uses the
AtlasDatabaseUser Custom Resources that you create in your Kubernetes cluster to manage resources in Atlas.
Upon the successful installation of the Kubernetes Operator, we are able to use the capabilities of the MongoDB Enterprise Kubernetes Operator to run MongoDB objects on our Kubernetes cluster. The Operator enables easy deploy of the following applications into Kubernetes clusters:
- MongoDB --- replica sets, sharded clusters, and standalones --- with authentication, TLS, and many more options.