Skip to main content

Command Palette

Search for a command to run...

Key Components of Kubernetes Architecture Explained

Updated
5 min read

Hii everyone, hope you all are good! This article is the next part of our previous article on the evolution of K8s and its history (link)! Here we are going to discuss K8s architecture in detail.

I will try to explain the things that are not easily available on the internet or are explained in a confusing way. I personally feel that there is a gap even in the official Kubernetes documentation, especially for beginners. The docs are great but sometimes they throw too much at you without building the foundation first!

Let's dive in and understand what really happens inside a Kubernetes cluster!

What is a K8s (Kubernetes) Cluster? Complete Guide for Beginners

K8s cluster is just combination of nodes. Now as you read the word node, the next word comes into your mind that what is a node! So node can be a physical or virtual machine on which k8s runs pods. In simple terms, it is a computer that can be physical or a virtual machine! Now in a K8s cluster, nodes can be of two types: one is master node (also called control plane node) and another one is worker node! You can set up K8s on your physical machine, cloud premises like AWS, Azure, GCP, on local computer, or on bare metal servers.

Master Node (Control Plane Node):

In a k8s cluster, those nodes that consist of control plane components are master nodes! I will explain what control plane is, but for now let's understand that master is nothing but a worker node that consists of control plane. And the most important thing to understand is that master nodes are used for managing the cluster and can also run workloads, though in production environments people usually keep them dedicated for management only!

So in general, in a k8s cluster, one physical or virtual machine that consists of control plane is called a master node, and master node means it has all the capability of a worker node. Master nodes basically control and manage the other worker nodes through the control plane components.

In a cluster, the number of master nodes can be more than one and it is always advisable to keep your master nodes in odd numbers (like 3, 5, or 7) for high availability and better fault tolerance! This helps in maintaining quorum for etcd. And yes, one master node runs the complete set of control plane components!

Worker Node: Where Your Applications Run

In a k8s cluster, every node can be a worker node, you can say! Meaning every machine can run workloads and pods! There are 3 main components of a worker node: kubelet, kube-proxy, and container runtime interface. I will go deeper into what each of those components does!

Control Plane Components: The Brain of Kubernetes

Control plane is a set of components and all together it is called control plane! The main components are API-server, etcd, Scheduler, Controller Manager, and Cloud-controller Manager.

1. API-server (kube-apiserver): It is the entry point of the k8s cluster. One can communicate with the cluster through the API-server using kubectl commands, REST APIs, or any Kubernetes client. It basically takes the data from etcd and gives the updates when we try to access by kubectl command! All communication in Kubernetes goes through the API server. It's the frontend of the Kubernetes control plane.

2. Etcd: It is the memory of the cluster, a distributed key-value store! It has every piece of information about the cluster like how many replicas are currently running and how many should be running, secrets, config maps, deployments, services, and everything is stored here! It is the single source of truth of the cluster. Without etcd, your cluster has no memory of its state!

3. Controller Manager (kube-controller-manager): Controller basically checks and compares the actual state and desired state from the etcd and works to match the actual state with desired state. Let's say there are 4 replicas needed for a particular pod and the running pods are 3, so controller detects the difference and tries to get 4 pods up and running there. There are many types of controllers like Replication Controller, Deployment Controller, Node Controller, etc., and all run inside the Controller Manager.

4. Scheduler (kube-scheduler): It basically checks on which worker node resources are available to place a new pod. It basically locates a node based on available resources (CPU, memory, storage) for the pod! The scheduler considers factors like resource requirements, hardware/software constraints, affinity/anti-affinity rules, and data locality when making scheduling decisions.

5. Cloud-controller Manager: This manages cloud-specific operations like provisioning load balancers, managing storage volumes, and handling node lifecycle when you're running K8s on cloud platforms like AWS EKS, Azure AKS, or Google GKE. It basically acts as a bridge between Kubernetes and your cloud provider's APIs.

Worker Node Components: Where the Magic Happens

1. Kubelet: It is also an API that runs on every worker node! It gives the information for the particular node and whenever a kubectl command is triggered, kube-api server talks with kubelet to get the status about that node! Kubelet is responsible for making sure containers are running in pods as expected. It takes instructions from the API server and manages the pod lifecycle on its node.

2. Kube-proxy: It is a network proxy that runs on each worker node! It helps to redirect the traffic from one pod to another pod and maintains network rules for pod communication. It enables the Kubernetes Service abstraction by maintaining network rules on nodes. These rules allow network communication to your pods from inside or outside of your cluster.

3. CRI (Container Runtime Interface): The actual space where the actual pods and containers are running! Common container runtimes include containerd, CRI-O, and Docker (though Docker is being deprecated). The container runtime is responsible for pulling images from registries, running containers, and managing container lifecycle.

Thank you everyone. If you want to hire me contact me in LinkedIn. Follow me more for more such content!