![]() In reality, little has to be changed to run across multiple clusters and those steps are described later.Įach member of the replica set will be run as its own pod with a service exposing an external IP address and port. We start by creating the entire MongoDB replica set in a single Kubernetes cluster (which would normally be within a single data center – that clearly doesn't provide geographic redundancy). This section goes to the next level of detail, showing how this can actually be implemented. Implementing a MongoDB Replica Set using Docker and KubernetesĪs described in the previous section, distributed databases such as MongoDB require a little extra attention when being deployed with orchestration frameworks such as Kubernetes. Consider creating your own image that contains both your preferred version of MongoDB and the MongoDB Automation Agent. That means it's important to use a strong monitoring and backup solution such as MongoDB Cloud Manager, included with MongoDB Enterprise Advanced and MongoDB Professional. It should be noted that while the orchestration framework might monitor the state of the containers, it is unlikely to monitor the applications running within the containers, or backup their data.If the orchestration framework provides automated rescheduling of containers (as Kubernetes does) then this can increase MongoDB's resiliency since a failed replica set member can be automatically recreated, thus restoring full redundancy levels without human intervention.Specifically, one MongoDB node within the intended replica set must be used to execute the rs.initiate and rs.add commands. This is likely to require some additional logic beyond that offered by off the shelf orchestration tools. Once each of the individual MongoDB nodes is running (each within its own container), the replica set must be initialized and each node added.With Kubernetes, this can be handled by associating a Kubernetes Service with each MongoDB node, which uses the Kubernetes DNS service to provide a hostname for the service that remains constant through rescheduling. For example, all containers within a Kubernetes Pod share a single IP address, which changes when the pod is rescheduled. All of the nodes within a replica set must know the addresses of all of their peers, but when a container is rescheduled, it is likely to be restarted with a different IP address. MongoDB database nodes within a replica set must communicate with each other – including after rescheduling.To solve this, features such as the Volume abstraction in Kubernetes can be used to map what would otherwise be an ephemeral MongoDB data directory in the container to a persistent location where the data survives container failure and rescheduling. In the event that a container fails, and is rescheduled, it's undesirable for the data to be lost (it could be recovered from other nodes in the replica set, but that takes time). Running MongoDB with containers and orchestration introduces some additional considerations: This post delves into the extra challenges you face when attempting to run and orchestrate MongoDB in containers and illustrates how these challenges can be overcome. The rich functionality, simple tools, and powerful APIs make container and orchestration functionality a favorite for DevOps teams who integrate them into Continuous Integration (CI) and Continuous Delivery (CD) workflows. Orchestration also controls how containers are connected to build sophisticated applications from multiple, microservice containers. Orchestration tools manage how multiple containers are created, upgraded and made highly available. Read the Enabling Microservices: Containers & Orchestration Explained white paper. Need an identical copy of your application stack in multiple environments? Build your own container image and let your development, test, operations, and support teams launch an identical clone of your environment.Ĭontainers are revolutionizing the entire software lifecycle: from the earliest technical experiments and proofs of concept through development, test, deployment, and support. Want to try out MongoDB on your laptop? Execute a single command and you have a lightweight, self-contained sandbox another command removes all traces when you're done. Read this post for the state-of-the-art in running MongoDB in Kubernetes. Both of these capabilities make working with MongoDB in Kubernetes much simpler and more robust. This post is now 2.5 years old, and neither MongoDB nor Kubernetes have been standing still! In particular, Kubernetes has introduced StatefulSets and we've introduced the MongoDB Enterprise Operator for Kubernetes.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |