Docker, Swarm, Kubernetes and Mesosphere
To build a substantial microservice application one needs to build on a platform that can manage large collections of distributed, communicating services. Thanks to the open source movement we now have an excellent collection of tools for building and managing microservices. These are
- Containers. This revolutionary technology that allows us an alternative to deploying services as heavy-weight virtual machines. “Containers” run on a host OS and use basic services such as kernel namespaces and resource isolation provided by that OS. Docker containers contain all the OS components and libraries needed by the app, various user-added files and apps and instructions for what process to run. Docker exploits the host OS namespaces for isolation, control groups for resource management. It uses the Union File Systems so that containers are built as layers on existing FS. The company Docker.com also provides a registry of dockerized tools and application that can be downloaded. We show an example of using Docker and the registry in another section.
- As noted the host OS for Docker need not be very heavy because each container will have its own OS features and libraries required by the application. CoreOS is a basic “stripped down” version of Linux that contains only those tools needed to support Docker containers.
The tools for managing clusters of microservices hosting containerized microservices are many. The ones we have tested are
- Swarm. Docker.com provides a tool for managing clusters of servers running Docker container instances. We tested Swarm on Azure using the client Docker-machine and it was relatively easy to bring up a cluster of machines and deploy apps. Swarm shows great promise but it is still beta quality and we found the documentation still rather sparse.
- Kubernetes was recently released by Google and is based on the cluster management tools they use. We also found it relatively easy to deploy Kubernetes on Azure using another tool called Weave to support the networking. Kubernetes has an important feature not present in the other microservice cluster management tools. In Kubernetes every container lives inside a “pod”. Pods can contain a single Docker container instance or several instances. This is important because often a single microservice instance may always collaborate with another microservice instance of the same or different type. For example a Dockerized web server may need a private instance of a Redis cache or SQL database. These are relatively standard docker components, so there is no reason to deploy them in your web server container. Because each pod instance runs on a single server, the containers in the same pod share resources such as private directories. Communication within a server is going to be faster and more reliable than communication across the network.
- Mesosphere. One of the many products from the UC Berkeley AMP lab was a distributed computing operating system (dcos) called Mesos. It has since been spun off as a startup called Mesosphere.com. Mesosphere installed easily on Azure and it has proven to be extremely reliable. Because we use it so extensively we have an addition page about it here.
- Microsoft Azure Service Fabric. Microsoft recently released a development kit for a microservice orchestration framework that they have been using internally for a while. The SDK is easy to install into visual studio and it comes with an emulator so you can start building apps. I have not yet had a chance to try the full deployment. Mark Russinovich has a nice blog about this and an online video of a talk he gave describing the system.