Docker Swarm Mode VS Kubernetes

Docker Swarm Mode and Kubernetes are two of the most popular tools for container clustering and orchestration, despite their divergent philosophies and capabilities. Since both platforms are quite distinct, experience with one generally won’t be helpful with the other beyond the common experience of building Docker images, which both use. This makes your initial choice of which to work with even more important.


What are Docker Swarm and Kubernetes?

Docker Swarm Mode and Kubernetes are two of the most popular tools for container clustering and orchestration, despite their divergent philosophies and capabilities. Since both platforms are quite distinct, experience with one generally won’t be helpful with the other beyond the common experience of building Docker images, which both use. This makes your initial choice of which to work with even more important.


Swarm mode allows developers and administrators to create and manage a virtual system, a “swarm,” that is composed of one or more Docker nodes. Every host in a given cluster runs a Swarm agent controlled by the Swarm manager(s), which schedules and orchestrates containers. The new features of Swarm mode include load balancing, service discovery, scaling, rolling updates, a secure data plane, and routing mesh.


Kubernetes is an open-source cluster manager for containers. It was originally designed by Google, who based its development on years of experience working with Linux containers. Kubernetes clusters are made up of several components: pods, labels, services, and replication controllers.


Pods are the basic unit of scheduling in Kubernetes. They are a group of containers intended to be deployed and scheduled together, coordinating to execute a particular task. If you were to deploy a single container, it would be deployed as a single pod.


Labels represent user-defined attributes that are attached to pods.

A service is a unit that acts as a basic load balancer and ambassador for other containers. Services are a way to interface with a group of containers; they allow you to simplify your container designs since they group together a logical collection of pods based on your labels.

Replication controllers are a framework for defining horizontally scaled pods. These replication controllers are responsible for handling replicated pods. If containers go down, replication controllers will start up another container and kill that container when the first one comes back online.


Installation

Since Swarm mode is a part of your Docker engine, there is no additional installation necessary after you install Docker 1.12. To deploy Docker Swarm, use a fixed IP address and assign it to a network interface available to the host operating system. You now have everything you need to create a swarm.


Kubernetes installation is more involved, but can be simple if you use the right tools. Installing Kubernetes with kubeadm (a tool that is part of Kubernetes 1.4) is ideal for integrating with existing orchestration systems or bare metal environments. Weaveworks has contributed to kubeadm with the goal of making Kubernetes easier to install. The advantage of Kubernetes is that you have more ultimate control over the configuration of the software. Furthermore, most common platforms now have documentation available on how to set up Kubernetes.


Features

Docker Swarm mode and Kubernetes are both feature-rich platforms that provide you with a rich panoply of features. For example, both solutions are compatible with Weave Net, our networking tool for connecting containers. Each have engaging communities for like minded enthusiasts to learn and collaborate. Both support persistent data storage via Kubernetes’ Persistent Volumes and Docker Swarm mode’s volume plugins. Because Swarm mode is part of Docker, you also have easy access to Docker’s native tools. A direct interface with tools, such as Docker Compose, isn’t available with Kubernetes, which works on top of Docker instead of with it.


Furthermore, the deployment of containers is handled differently between Swarm mode and Kubernetes. The winner here really depends on whether you prefer working with the native Docker tool set. Docker deployments are typically done through Docker Compose or the Docker command line. In Kubernetes, container deployment is usually done via kubectl, which is difficult to use because of Kubernetes’ complex and layered APIs. This, however, makes Kubernetes deployment more expressive.


Performance

Both Docker and Kubernetes claim to support clusters of up to 1,000 nodes with no performance degradation; Docker also claims to support up to 30,000 containers with no dip in performance. According to Kubernetes, 99 percent of its API calls return within one second, and 99 percent of Kubernetes pods and containers will open within five seconds.


Thanks to Swarm mode, the performance gap between Kubernetes and Docker is closing. Before Swarm mode was even introduced, a March 2016 study by Jeff Nickoloff evaluated the performance of both Docker Swarm and Kubernetes while running 30,000 containers on 1,000 node clusters. Nickoloff found that Swarm was roughly five times faster than Kubernetes when initializing a new container. But, he was impressed by the Kubernetes replication controller, which allowed him to create 3,000 container replicas in under 155 seconds. It should also be noted that this study was comparing setup time and not application performance.

“Currently, DevOps is more like a philosophical movement, not yet a precise collection of practices, descriptive or prescriptive.” ~ Gene Kim