Kubernetes Architecture

ujjwal bansal
Towards Dev
Published in
4 min readApr 14, 2022

--

The below image shows how our applications live inside the machines when we host them. It is the case when these hosting machines have no Kubernetes installed on them.

Figure — 1

Let’s consider a case where these applications are stored inside containers. And Kubernetes is running on our machine. We try to understand Kubernetes architecture by considering a real-life situation.

As shown in figure-2 when Kubernetes is installed on our machines it split those machines into two groups.

  1. Few of these work as Master nodes.
  2. The rest of the machines are allocated for Worker nodes.
Figure -2

Worker nodes are the machines that will run our actual workloads. On the other hand, the Master node is where our logic lives which knows how to control other worker nodes running in the cluster. Figure — 3 shows the interaction between these nodes and the user.

Figure — 3

Question: Suppose we are running Kubernetes on one of the cloud providers like Azure, Google, or AWS then what is the scenario?

Solution: From the above discussion, we can conclude that if we are using the Kubernetes service through any of the cloud providers then the Master node is in under their control and we need to take care of only worker nodes.

Until now we have just gotten a glimpse of Kubernetes. To understand more about its architecture we need to look inside the Master and Worker Nodes. Figure -4 briefly describes all the components of Kubernetes architecture and how they are connected.

Figure -4: Kubernetes architecture

Master Node

Part -1: We can interact with Kubernetes using a CLI tool called Kubectl or any UI interface.

Part -2: API server exposes the Kubernetes API to the end-user due to which we are able to communicate with Kubernetes. For example, if we want to create a pod then we have tell to the API server that we need a pod in this particular cluster. It also authenticates the user and checks the authority of the user he/she has authority to make changes in the cluster or not.

Part -3: All the necessary details which API server is getting from a user, all the cluster-related data, and since Kubernetes is coordinating a lot of tasks such as configuration, deployment, service discovery, load balancing, job scheduling, and health monitoring across the across all clusters. In order to achieve this coordination Kubernetes stores this information in Key value format with consistent and high availability in etcd.

Part -4: The main task for Scheduler to watch newly created Pods with no assigned node, and select a node for them to run on. For example, we created a Pod that requires 1GB of memory and there is 3 worker nodes running in our cluster named A, B, C. Now Scheduler needs to decide on which node it can run this newly created Pod. A and B worker node does not have enough memory. But C worker node used only 500MB out of 2GB. So, it schedules that Pod on worker node C.

Part -5: Controller basically senses each object running in the Kubernetes cluster to check they are running in a healthy state or not. There are separate controllers for each and every object in Kubernetes. For instance, there is node controller which is responsible for noticing and responding when nodes go down, Job controllers, Endpoints Controllers, Service Account and Token controllers, etc.

Worker Node

There are 3 major components in Worker nodes i.e, Kubelet, Kube-Proxy and Container-runtime.

Part -6: Kubelet is an agent that runs on each node in the cluster. It makes sure that containers are running in a Pod.

Part -7: Kube-Proxy maintains network rules on nodes. These network rules help pods to communicate with each other even if they are in different nodes. Consider figure-5 which broadly shows that Pod A and Pod E which are present in two different nodes can communicate via network rule setup by Kube-Proxy. There is more to discover what more these components offer but broadly we have discussed their functionality.

Figure -5

Part -8: container runtime is the software that is responsible for running containers. Kubernetes support many more container runtime other than Docker such as CRI-O, containerd, etc.

Conclusion

I hope this article helps you understand the Kubernetes architecture and familiarize you with its components.

References

YouTube videos

--

--

Propagating a life-changing perspective to everyone is my motive. Writing my own expirences or learnings to empower others.