Getting started with Kubernetes

ยท

4 min read

What is Kubernetes?

Kubernetes is a portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem.

In simple words, Kubernetes is a "container orchestration platform."

Why use K8s if we have Docker?

Docker containers are ephemeral in nature. This means that they are designed to be temporary. They die and get revived easily. Problems of Docker are:

  1. Single Host System:

    There is only 1 single host in Docker. This means that if one container dies inside a host, the load on other containers increases.

  2. No Autohealing:

    Let's say a container is down. Now without manual user intervention, it is not possible to revive the containers. This disrupts the workflow and hence autohealing property is necessary for production based systems.

  3. No Autoscaling:

    Let's say we are hosting an e-commerce website. Now suddenly the traffic on it increases due to some festival or sale, so instead of 1 container we have to use 10 containers to handle the load otherwise the website will crash. In Docker, we have to manually increase the number of containers. This is a problem hence autoscaling property is also needed.

  4. No Enterprise Level Support:

    Docker is very simplistic. It doesn't provide Enterprise level support. This includes Load balancer, Firewall, API Gateways and many more such properties which are a need in production ready environments. Hence, Docker is never used in production.

Here is where Kubernetes comes into the picture.

  1. By default, K8s is a cluster(group of nodes). This solves the single host problem of docker.

  2. K8s has something called as Horizontal Pod Autoscaler (HPA) which increases or decreases the number of pods as per requirement "automatically".

  3. K8s controls and fixes the damage done to containers using kubelet.

    (kubelet is a part of k8s architecture)

  4. K8s is an Enterprise level Orchestration platform. It provides enterprise level supports like API Gateways, Firewall, Monitoring, Service Meshes etc

So now we know why K8s is needed and how it is different from Docker.

Kubernetes Architecture

After knowing what K8s is and why is it needed, next thing is knowing its architecture. So , as I said before, K8s is a cluster. So basically, it follows a master slave architecture. There are master nodes and there are slave or worker nodes. The K8s architecture is divided into 2 parts:

  1. Control Plane

  2. Data Plane

Components of Control Plane:

  • API server

  • etcd

  • scheduler

  • Controller Manager (CM)

  • Cloud Controller Manager (CCM)

Components of Data Plane:

  • kubelet

  • kubeproxy

  • container runtime

Container vs Pod vs Node vs Cluster

When I first started learning about K8s, this was very confusing to me so I'll try to clear it out.

Container

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Pod

A Pod is the smallest deployable unit in Kubernetes. It represents a single instance of a running process in your cluster and can contain one or more containers that share the same network namespace and storage volumes. A YAML manifest is associated with a pod. It contains the running specifications of the container. YAML stands for YAML Ain't Markup Language which is a human-readable data serialization language like JSON. A pod can have multiple containers inside it. Let's say 1 pod has 2 containers. Here, the 2 containers share network, storage, Labels etc.

Node

Nodes are basically machines which run the pods. These can be virtual machines like AWS EC2, or physical machines. Nodes run the pods which contain the containers which actually have the software to be executed.

Cluster

A cluster in Kubernetes is a set of nodes (machines) that run containerized applications managed by Kubernetes. The cluster is the overarching structure that encompasses all the nodes and orchestrates the deployment and management of containers.

A diagram for your reference:

Summary

Kubernetes is a powerful, open-source platform for managing containerized workloads, offering features like autohealing, autoscaling, and enterprise-level support, which Docker lacks. Kubernetes utilizes a cluster architecture with master and worker nodes, and key components include the API server, etcd, scheduler, kubelet, and more. Understanding the distinctions between containers, pods, nodes, and clusters is crucial for grasping Kubernetes' functionality. This article aims to provide a clear explanation of these concepts.

That's it for this article.

Hope you found it useful and got an idea of what Kubernetes is :)

If you feel anything is wrong in this article or have any other feedback, you can reach out to me.

Happy Learning ๐Ÿ˜Š

LinkedIn

ย