Blog

Stateful Container Services on Nutanix Part 2: MongoDB

  • 29 November 2016
  • 0 replies
  • 40193 views
Stateful Container Services on Nutanix Part 2: MongoDB
Userlevel 4
Badge +12
This post was authored by Ray Hassan, Sr. Solutions & Performance Engineer at Nutanix and Kate Guillemette, Technical Writer & Editor, Solutions & Performance at Nutanix.

In our last post on stateful containers, we talked about using the Nutanix-Docker integration components to configure and run stateful (“pet”) applications or long-running services in containers. Many organizations have been reluctant to try running their pet workloads in containers, at least in a production setting. Using MongoDB as a test case, I hope to provide some assurance that containers aren’t just for short-lived applications anymore.


Source: https://twitter.com/mfdii/status/697532387240996864 (Used with permission.)

Using containers to bring up a cloud-native database application like MongoDB is nontrivial to do right. I don’t plan to cover every aspect of a production deployment at this stage, but future solutions-based work in this area will work on it. You can see from the image above that there is far more to deploying containers than the docker pull/docker run sequence.

First, let’s consider the virtual host provisioning and data persistence aspects of a stateful deployment.

Installation and Setup


First off, we need to download the Docker Machine driver for Nutanix along with the CentOS container host image from the Nutanix portal. Upload the container host image to the Acropolis Image Service and copy the Docker Machine driver to a directory on your Docker CLI host. In these examples, the CLI host is a Linux VM running on my desktop, but Nutanix also provides drivers for Mac/OSX and Windows—just adapt the instructions accordingly. I’ve tried to capture all of the required installation steps below, but if you need more details, please download the Acropolis Container Services Guide.

[ Related Reading: Stateful Container Services on Nutanix Part 1 ]

Ensure that you are running AOS version 4.7 or later and assign a dataservices IP to the cluster via either Acropolis Prism or nCLI.



  • Download the CentOS container image to your laptop or workstation from the Nutanix support portal, then upload it to the Acropolis Image Service—the example below uploads directly from the portal URL.



The next step is to download the Docker Machine driver from Nutanix and install it into my Linux VM.



Now we’re ready to spin up Docker Machines on the Nutanix platform.

Nutanix Docker Machine and Volume Driver

The Nutanix Docker Machine driver allows us to deploy VMs with Docker Engine preinstalled, much like you could do in a public cloud. The difference is that the VMs run on Nutanix AHV, the hypervisor that underpins the Nutanix Enterprise Cloud Platform. Using the create option, you can customize your Docker Machines, not only with VM sizing and base OS configuration, but also with the Nutanix driver itself. This flexibility means that we can generate VMs in various sizes. The following command line help option shows some of the additional parameters you can supply to the Nutanix driver when building out Dockerized machines:



This command returns Nutanix driver-related options that allow you to create VMs with the desired RAM (--nutanix-vm-mem) and CPU or core count (--nutanix-vm-cpus or --nutanix-vm-cores) using the docker-machine CLI.

Now that we’ve seen how to tailor VM specifications, it’s time to create some machines using the Nutanix driver. Let’s start by setting up three Dockerized VMs. Each VM runs a MongoDB instance that will eventually form part of a replica set.


The intention is to use the Docker ecosystem components (Machine, Compose, and so on) to make a repeatable, automated build process for our MongoDB instances. The command line syntax for each host follows the same format.



In the Docker Machine command above, we’re creating a Dockerized VM called dbhost01. We specify the Nutanix machine driver, the Nutanix Prism network endpoint, and the user credentials for talking to the Prism API. We also call out the CentOS container host image and the network (vlan.68) where the VM should run. I added in a few extra options that set CPU and RAM resources a little above default, at one CPU, eight cores, and 1 GB RAM—it’s going to run a database, after all!

Next, we can choose how we administer Docker on the newly minted VM: either connect to the machine directly via SSH or run the eval command string locally and talk remotely to Docker Engine on the Docker machine host (VM). Let’s do a little of both to show you the options:

  • Set up the Docker Machine connection environment.



  • Now we are talking to the Docker daemon on the new machine. Pull the Nutanix volume plugin from its repository if required—the start-volume-plugin.sh script should already be installed on the VM in the root home directory, however.



  • Connect to the Docker Machine and configure the Nutanix volume plugin:



In total, create three Dockerized VMs and deploy them on the Nutanix platform. Each one has the Docker Engine and the Nutanix volume plugin installed, so we can create persistent volumes for the database instances.

You can find these VMs in the Prism GUI under the VM → Table dropdown menu and manage them like any other VMs. The Acropolis DHCP/IPAM facility assigns them an IP address. Even after creation, you can change the number of cores or the memory capacity as shown below.




Here we have our Dockerized VMs up and ready to host services. In the next post, we’ll cover the setup of a MongoDB replica set, using the Nutanix volume plugin to create persistent storage on the DSF.

If you’re working on stateful services that are running in a hybrid cloud environment, we would love to talk more and share experiences. Get in touch with us via our social media channels or the Nutanix Community Forums.

Additional Information

The Intersection of Docker, DevOps, and Nutanix
Containers Enter the Acropolis Data Fabric


Disclaimer: This blog contains links to external websites that are not part of Nutanix.com. Nutanix does not control these sites, and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such site.

This topic has been closed for comments