Understanding Kubernetes

Upanshu Chaudhary
5 min readJun 19, 2021

If you are a microservice developer or a DevOps engineer there is a good chance you came across Kubernetes. Many tech giants have adopted it for orchestrating their containers. let us try to understand what it is and why it is so popular.

Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. This is the Wikipedia definition and this is the simplest one out there. But let us elaborate on this.

What do we mean by container-orchestrator?

In today’s world whenever we build any application using the microservice architecture we use docker containers to deploy them because these containers encapsulate everything that the service needs to run and help us to easily change environments if we need to do without affecting the containers. Because we are talking about microservice architecture we will most probably be dealing with multiple containers. Multiple containers running in production can be 2,3, a dozen, or even thousands and they need to be continuously deployed, updated, managed, connected, scaled up and down, redeployed, etc. Doing these tasks manually will be a nightmare and would require a good workforce. Now, this is where Kubernetes knocks at our door and makes our lives easier.

So basically Kubernetes also known as K8S helps us

  • Automation
  • Storage orchestration
  • deploy containers as well as manage applications
  • scale them up and down according to demand
  • Automates rollouts and rollbacks
  • Self-monitoring/healing

Whenever we say we are running K8S it actually means that we are running a Kubernetes cluster. A K8S cluster is a set of nodes(virtual or physical machine) that runs containerized applications.

The K8S cluster has 2 main components.

  • Master node
  • Worker node

Kubernetes master node contains a Control Plane which also consists of several components.

The master node — Kubernetes control plane

The master node is the brain of Kubernetes. It runs all the cluster’s control plane services. This is where everything is controlled and decisions are made.

It is made up of several components in the master node:

  • Scheduler — it is responsible for tracking pods and assigning them to nodes based on some parameters like node health, node resource availability, port availability of the pod.
  • Cluster store — It stores the state of a cluster. It uses etcd to do this.
  • Controller manager- It is the Daemon that manages the control loop. It continuously looks for changes in the API server to achieve the desired state. There are different types of controllers like this. It is the controller of controllers.
  • Node controller — It is responsible for checking the current state of the node to the desired state of the node and reacts to those changes. If one node dies, it is the responsibility of the node controller to bring in a new node to replace the old node.
  • ReplicaSet controller — It is responsible for making sure that we have the correct number of pods running
  • Service account and token controller — They are responsible for creating account a and API access for new namespaces.
  • Endpoint controller which assigns pods to services.
  • Cloud controller manager is responsible for interacting with cloud providers like AWS, Azure, and GCP.

All these communicate to each other using the API server which acts as the frontend for the Kubernetes control panel.

We interact with K8S using this API server which exposes a Restful API on port 443.

It is also responsible for Authentication and authorization checks.

Even when we interact with external clients like kubectl, the manifest yaml interacts with the API server to communicate, which in turn passes on the yaml to etcd.

etcd is an external service adopted by the K8S backend to store cluster state and configuration. It is also adopted by OpenStack for the same purpose.

Worker nodes

This is where containerized applications run. A working node can be a virtual or physical machine that provides an environment to run applications. Every cluster has at least one worker node.

Three main components of worker node

Kubelet

It is a Kubernetes agent and it runs on every node. It is very obvious that Kubernetes needs someone to tell it what is the state of the pods running in the node and associated reports. It interacts with the Kubernetes API server and can register pods. It also interacts with the container runtime and runs containers that are pulled by it.

Container Runtime

It is a software in K8S responsible for

  • pulling images from the container from repositories such as docker hub
  • Starting those containers
  • Stopping those containers.

It consists of CRI Container Runtime Interface

Kubernetes supports docker, containerd, CRI-O, and any implementation of Kubernetes CRI. Docker was a widely used container runtime but Kubernetes deprecated it and adopted containerd.

Kube proxy

It is responsible for maintaining network rules for the pods. It makes sure that each node gets its own unique IP address, routing network traffic to load-balanced services, and responsible for local cluster networking.

These are the basic components of Kubernetes, all this will make more sense when you do some hands-on with Kubernetes.

When I was understanding the basic architecture of Kubernetes I was fascinated but I had two questions in mind at the end. So I will discuss them as well.

Can we use Kubernetes for monoliths?

Lightweight applications or monoliths which do not need orchestration management do not need to use K8S. It would seem more of an overhead than a benefit.

What happens when the master node fails?

If the master node fails then the worker node fails as well. We can set up multiple master nodes in case one fails and the other will take its place.

Also, something to know is that Kubernetes is very complex if we are the ones managing it because then we need to define all the granular details and setup steps for the master node, to make our lives easier many cloud providers provide managed Kubernetes service, for example, EKS from AWS and Google Kubernetes Engine from GCP.

--

--

Upanshu Chaudhary

Graduate Teaching Assistant and Student at Oregon State University. Open-source enthusiast. Probably busy reading code on a Random github profile.