Why need containers and Kubernetes - I

Why need containers and Kubernetes - I

ยท

4 min read

Kubernetes also known as K8s was built by Google based on their experience running containers in production. It is now an open-source project and is arguably one of the best and most popular container orchestration technologies out there. In this post, we will try to understand Kubernetes at a high level. To understand Kubernetes, we must first understand two things Container and Orchestration. Once we get familiarized with both of these terms we would be in a position to understand what Kubernetes is capable of. We will start looking at each of these next.

We are now going to look at what containers are, specifically, we will look at the most popular container technology out there Docker. If you are familiar with Docker.

Why do we need containers?

Let me start by sharing how I got introduced to Docker. In one of my previous projects, I had this requirement to set up an end-to-end stack including various technologies like a Web Server using NodeJS and a database such as MongoDB, messaging system like Redis, and an orchestration tool like Ansible. We had a lot of issues developing this application with all these different components. First, their compatibility with the underlying OS. We had to ensure that all these different services were compatible with the version of the OS we were planning to use. There have been times when certain versions of these services were not compatible with the OS, and we have had to go back and look for another OS that was compatible with all of these different services.

Secondly, we had to check the compatibility between these services and the libraries and dependencies on the OS. We have had issues where one service requires one version of a dependent library whereas another service required another version.

The architecture of our application changed over time, we have had to upgrade to newer versions of these components, or change the database, etc, and every time something changed we had to go through the same process of checking compatibility between these various components and the underlying infrastructure.

But when we introduced containers we have these all on the same VM and the OS, but within separate environments or containers. We just had to build the docker configuration once, and all our developers could now get started with a simple โ€œ docker runโ€ command. Irrespective of what underlying OS they run, all they needed to do was to make sure they had Docker installed on their systems.

Containerization, Great but then why Kubernetes

So we learned about containers and we now have our application packaged into a docker container. But what next? How do you run it in production? What if your application relies on other containers such as database or messaging services or other backend services? What if the number of users increases and you need to scale your application? You would also like to scale down when the load decreases.

To enable these functionalities you need an underlying platform with a set of resources. The platform needs to orchestrate the connectivity between the containers and automatically scale up or down based on the load. This whole process of automatically deploying and managing containers is known as Container Orchestration.

Kubernetes is thus a container orchestration technology. There are multiple such technologies available today Docker has a tool called Docker Swarm. Kubernetes from Google and Mesos from Apache. While Docker Swarm is easy to set up and get started, it lacks some of the advanced autoscaling features required for complex applications. Mesos on the other hand is quite difficult to set up and get started but supports many advanced features. Kubernetes arguably the most popular of it all is a bit difficult to set up and get started but provides a lot of options to customize deployments and supports the deployment of complex architectures. Kubernetes is now supported on all public cloud services providers like GCP, Azure, and AWS and the Kubernetes project is one of the top-ranked projects on GitHub.

Advantages of Kubernetes

  • There are various advantages of container orchestration. Your application is now highly available as hardware failures do not bring your application down because you have multiple instances of your application running on different nodes.

  • The user traffic is load balanced across the various containers. When demand increases, deploy more instances of the application seamlessly and within a matter of seconds and we can do that at a service level.

  • When we run out of hardware resources, scale the number of nodes up/down without having to take down the application. And do all of these easily with a set of declarative object configuration files.

Want to learn and explore more about Kubernetes? Then do check out the Kubernetes blog series

Hop into the blog section for a more interesting and detailed overview of Software development and other stuff. ๐Ÿ˜Š

Did you find this article valuable?

Support Rohit Sah by becoming a sponsor. Any amount is appreciated!

ย