Kubernetes vs Docker Swarm: Which to Learn
| devops - Erik Mikac

Kubernetes vs Docker Swarm: Which to Learn

Whenever someone brings up terms like containerization and app orchestration, most people's minds go straight to Kubernetes. And there’s a good reason for that — over 3/4 of companies surveyed by CNCF chose Kubernetes as their go-to containerization platform. Its easily configurable YAML files and cloud native integration have made Kubernetes a boon for many organizations.

However, not everyone is using Kubernetes. For example, the aforementioned survey indicates that 22% of respondents use a different technology — and one of those technologies is undoubtedly Docker Swarm. Swarm is an orchestration platform that is controlled directly from the Docker CLI, meaning Swarm comes out of the box with Docker installations. Docker Swarm is very similar to Kubernetes. It allows users to add redundancy, security, and orchestration to a large number of containerized production apps.

If you are not particularly well-versed in container technology, it may be difficult to decide which technology best suits your needs. That's why we'll discuss both Kubernetes and Docker Swarm at a high level — and then compare the two and decide which one is right for your needs.

What is Kubernetes

It would be difficult to compare Kubernetes and Docker Swarm without discussing the Kubernetes itself. It was created by Google and released back in 2014. While at Google, it proved to be suitable for any workload imaginable. Now it's an open-source platform and maintained by the Cloud Native Computing Foundation (CNCF).

The back-bone of Kubernetes is the Docker container. Without the docker container, there would be no Kubernetes. Containers house your applications. Kubernetes creates pods, which store one or more containers. Finally, all of the pods span across multiple nodes. Nodes are simply physical or virtual machines that the pods are stored on. The pods make up the basic building block of Kubernetes. While pods may be the building block of Kubernetes, it is the concept of desired-state that makes Kubernetes invaluable.

Desired-state describes the state of the objects in your environment. For example, how many pods should be replicated, how much memory should be used, and which external services it ought to communicate with? Once the desired state is declared in the YAML file, Kubernetes is programmed to ensure that the desired state is always met. In one possible scenario, the desired-state may require that five pods are always online at all times. If this is the case, then the Kubernetes cluster will self-heal and create a new pod in case one of those five pods goes down for some reason. It is important to note that a Kubernetes pod is never "brought back to life".

Once it dies, it dies. However the replica-set will ensure that a new pod is spun up.

This is all very high level, but hopefully it will give some context before we compare Kubernetes to Docker Swarm.

What is Docker Swarm

Docker Swarm is Docker's native container orchestration tool. Swarm is a little bit older than Kubernetes, being released in 2013. It is managed by Docker Inc., and it is open source just like Kubernetes. The backbone of Docker Swarm is — you guessed it — Docker containers. The fact that both the container and the orchestration framework are managed from the same command line interface is a big plus for Swarm. Swarm takes a group of containers and allows them to work in one cohesive unit.

The basic building block of a Swarm is called the node. The node is simply an instance of a container running in a managed Swarm cluster. Every cluster of nodes will have worker nodes and at least one manager node. The manager node doles out various tasks to the worker nodes. Think of tasks as pieces of work that are used to maintain some desired state. Just like in Kubernetes, the manager node will tell the worker nodes to always have five available nodes. These nodes will perform tasks such as load balancing.

As you may have discerned, these two technologies are similar from a practical standpoint. So when would it be right to use one over the other? As mentioned before, Docker Swarm uses the native Docker CLI.

Kubernetes vs. Swarm

Now that we have a better understanding of both technologies, let's discuss best case scenarios for each one. After all, business scenarios are legion, and one tech stack could be considered overkill for a particular purpose, or lacking in other purposes.

Kubernetes is the end-all-be-all for container orchestration and management. If you are working on an enterprise-sized application, then Kubernetes is your best bet. It has been utilized by countless business scenarios at Google, and has proven it can handle the workload. In terms of scalability, availability and load balancing, Kubernetes has got you covered. It is a one-stop-tool for all dev ops needs. Kubernetes greatest asset is the sheer amount of configuration that can be leveraged to suit every possible need.

Its greatest asset could be considered its greatest drawback for some, though. The requisite knowledge on cluster management and its sheer complexity can make Kubernetes feel intimidating. Furthermore, you are required to learn Kubectl, Kubernetes very own command line interface. Its inherent complexity may be why the CNCF offers two certifications to learn it: Certified Kubernetes Administrator and Certified Kubernetes Application Developer. All that being said, what if your needs aren't quite as grandiose as an enterprise application? That is where Docker Swarm comes into play.

Docker Swarm is the perfect solution for a smaller web application. It is quick to set up, easy to manage, and unlike Kubernetes, does not require the user to learn a new command-line interface. If you are managing a small website that is not expecting a huge amount of traffic, then Swarm would be great here. In fact, Kubernetes could very well be overkill. It's better in this situation because creating and managing a swarm is far easier to manage than a Kubernetes cluster is. The best aspect to Docker Swarm is that "it just works" with very little set up or maintenance. For many small scale businesses, this would probably be all they need.

Final Thoughts

To summarize, it will be fairly evident on which technology to use given your situation. If it is for a large enterprise application, go with Kubernetes. Docker Swarm just doesn't have all of the design options that are incorporated into Kubernetes. However if it's a small application, a personal website, or anything similar, it would be more useful to use Docker Swarm.



Ultimate Project Management Cert Guide

A 49-page guide to every PMI, Scrum, and ITIL certification, and how they fit into your career.

I have read and understood the privacy policy, and am able to consent to it.