Kubernetes is an open source orchestrator for containers that lets you better manage and scale your applications. You describe your applications and how they should interact with each other, and Kubernetes takes care of the rest. With Kubernetes you can orchestrate many containers on several hosts, scale them as microservices, and deploy updates and rollbacks with zero downtime.
Kubernetes is great at managing stateless applications. You provide a configuration which describes the “desired state” of your deployment and Kubernetes takes care of the rest. For example, you can create a container that spins up your static website. Then, you can instruct Kubernetes to manage three replicas of the application on different host machines. In case of a host failure, Kubernetes will automatically start the container on another host to achieve the desired state—three running replicas. You can also scale up or down the number of replicas while the application is running.
What if your application needs a persistent storage solution? You may decide to spin up a MongoDB database instance and host it on a separate host machine. But MongoDB is designed to be deployed in its own distributed systems, with replica sets for high availability and sharding for scalability. Kubernetes is designed to be a general-purpose container orchestrator—it doesn't have the knowledge to manage MongoDB topologies. Nor does it know how to provision database users or control other internal aspects of MongoDB. How can we manage a MongoDB cluster, or any database, with Kubernetes? Enter Kubernetes operators.
Kubernetes operators allow you to control applications that require domain knowledge. Kubernetes operators are maintained by domain experts and are available for use in any Kubernetes environment. They track and manage objects called Custom Resources (CRs). These objects extend the Kubernetes API with domain-specific functionality.
For example, a database operator might extend the Kubernetes API with custom resources such as Database
and DatabaseUser
. These resources are deployed to Kubernetes clusters and are managed by the operator. The operator can scale up and down the number of replicas of the database, or authenticate users. The operator can also effectively manage authentication across different environments with a centralized configuration.
MongoDB officially supports three Kubernetes operators: the MongoDB Atlas Operator, the MongoDB Enterprise Operator, and the MongoDB Community Operator. The MongoDB Community Operator can be used for simple deployments. Let’s take a look at the other two.
The MongoDB Atlas Operator for Kubernetes allows you to manage MongoDB Atlas, MongoDB's database-as-a-service platform, natively from Kubernetes. You can provision MongoDB Atlas projects, clusters, and users. The operator keeps your deployment in the desired state by making API calls to MongoDB Atlas. With the Atlas operator, you can configure your Atlas clusters without ever leaving Kubernetes.
For more information about the MongoDB Atlas Kubernetes operator, visit the dedicated documentation page.
The MongoDB Enterprise Operator for Kubernetes lets you deploy and manage MongoDB database resources to a Kubernetes cluster. You can deploy standalone instances, replica sets, and sharded clusters. Whichever you choose, the operator will control the lifecycle of the deployment, making sure it is always kept in the desired state. You can also upgrade the running MongoDB version, scale your deployment, and resize the storage when needed. The Enterprise Operator is available for MongoDB Enterprise Advanced customers.
To learn all about the MongoDB Enterprise Kubernetes Operator, visit the dedicated documentation page.
MongoDB supports Kubernetes by providing three official Kubernetes operators: MongoDB Community Operator, MongoDB Enterprise Operator, and MongoDB Atlas Operator. The MongoDB Community Operator can be used for simple deployments of MongoDB Community. The MongoDB Enterprise Operator, available with MongoDB Enterprise Advanced, enables MongoDB standalone instances, replica sets, and sharded clusters to be managed by Kubernetes. The MongoDB Atlas Operator allows you to create and manage your cloud-based MongoDB Atlas projects and clusters. All of the operators make it possible to integrate MongoDB with your Kubernetes environment and the apps that you run there.
To create a forever-free cluster in MongoDB Atlas and control it from Kubernetes, check out the quick start guide.
Kubernetes is a platform for orchestrating containerized applications. Kubernetes has many useful features that make the process of managing containers easier. Learn more about MongoDB and Kubernetes.