Kubernetes: An Overview of its Architecture and Main Components
Tags: kubernetes, devops, k8s, docker
Published: 2024-02-29 13:53:05

In the modern software development landscape, containerization has become the preferred approach for packaging and deploying applications. It facilitates consistent and efficient delivery across diverse computing environments. However, managing a large number of containerized applications can be complex and time-consuming.

Kubernetes provides a robust and automated solution for container orchestration, streamlining the deployment, scaling, and management of containerized workloads. Through declarative configuration and automated operations, Kubernetes empowers teams to achieve higher efficiency, agility, and scalability in their software delivery pipelines.


![Cluster Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zk0g4orkqaa81q5r3e3l.png)

## **Kubernetes Components**

When you deploy Kubernetes, you create a cluster, which is a group of machines working together to manage containerized applications. These machines are called worker nodes, and they are responsible for running the actual containerized applications. Each cluster must have at least one worker node.

Within the cluster, pods serve as the smallest deployable units. Each pod can contain one or more containers, along with their shared storage.

The control plane acts as the brain of the cluster, managing both the worker nodes and the pods. It's responsible for ensuring everything runs smoothly and efficiently. In production environments, the control plane typically runs across multiple machines to provide fault tolerance and high availability. This means that if one machine fails, the cluster can still function without disruption.

Overall, a Kubernetes cluster offers a robust and scalable way to manage and deploy containerized applications.

### Control Plane Components

**kube-apiserver:**

Every interaction with a Kubernetes cluster goes through the kube-apiserver, the central component of the control plane. Imagine it as the central hub, the single point of entry for all communication and requests. It exposes the Kubernetes API, a standardized way to manage cluster resources like Pods, Services, and Deployments.

Built for Scalability: Unlike a traditional office with one receptionist, kube-apiserver is designed to scale. You can have multiple instances of kube-apiserver working together. This way, the workload is balanced, ensuring smooth operation even during high-traffic periods. Multiple instances working together make the system more resilient and capable of handling heavy demands. 

**kube-scheduler:**

Have you ever had to find the perfect desk for a new team member? The kube-scheduler takes on a similar role in the cluster. It constantly monitors newly created Pods (containerized applications) that haven't been assigned a specific worker node.
The kube-scheduler considers various factors like resource requirements, hardware compatibility, and data locality to make informed decisions and assign each Pod to the most suitable worker node.

**etcd**

In the realm of Kubernetes, etcd functions much like the central nervous system does in the human body. It serves as a dependable and consistent repository, storing critical cluster data essential for the functioning of various components such as Pods, deployments, and services. Without etcd, the cluster would lack the essential information needed to operate effectively, akin to a body without its brain.

Similar to how the body requires a backup plan to safeguard its nervous system, implementing a robust backup strategy for etcd is imperative to ensure data safety and maintain the cluster's integrity. Without such measures, the loss of etcd data could have severe repercussions, akin to the consequences of losing vital information for the body's central nervous system.

**kube-controller-manager**

Operating tirelessly behind the scenes, the Kubernetes Controller Manager plays a vital role in ensuring a stable and organized cluster. This core control plane component acts as a conductor, overseeing numerous specialized controllers.

These controllers, vigilant through the API server's watch feature, meticulously monitor specific aspects of the cluster, like the number of running pods or the lifecycle of namespaces. When a discrepancy arises between the desired and actual state, the controller steps in, making adjustments to steer the cluster back toward its intended configuration.
For example, the Replication Controller ensures the specified number of pod replicas are running for a deployment, while the Endpoints Controller maintains accurate service endpoint information. Beyond its control loop duties, the Controller Manager also performs crucial housekeeping tasks. It manages the lifecycle of namespaces, ensuring proper organization within the cluster.

Furthermore, it acts as a diligent cleaner, removing unnecessary resources such as outdated events, terminated pods, and orphaned resources created through cascading deletions. By seamlessly managing both ongoing operations and housekeeping, the Controller Manager plays a critical role in maintaining a healthy and well-functioning Kubernetes cluster.

### Node Components

Node components run on every node, maintaining running pods and providing the Kubernetes runtime environment.


**Kubelet**

Imagine a tiny robot tirelessly working on each computer in a large network. That's essentially the role of the Kubelet in a Kubernetes cluster. This essential agent resides on every `node`, acting as the primary caretaker of containerized applications.

The Kubelet receives instructions, known as PodSpecs, outlining the desired configuration for containerized applications (Pods). It then diligently works to ensure these containers are up and running, constantly monitoring their health and making necessary adjustments to keep them operational.

However, the Kubelet doesn't meddle with any containers not created by Kubernetes. It focuses solely on keeping the applications orchestrated by the larger Kubernetes system functioning smoothly.

**kube-proxy**

Kube-proxy, the unsung hero of your Kubernetes cluster, ensures smooth communication between services and pods. This network proxy resides on each `node`, functioning like a traffic cop. It directs network traffic from both within and outside the cluster to the appropriate destinations.
Kube-proxy utilizes the operating system's built-in traffic management features whenever available, but it can also take charge and directly forward traffic itself. This adaptable approach ensures seamless communication within your cluster, regardless of the underlying infrastructure.

**Container runtime**

In the heart of a Kubernetes cluster lies the container runtime, the invisible conductor of the containerized application orchestra. This essential component meticulously manages the lifecycle of each container, from pulling images and allocating resources to running the application and ensuring its smooth operation. Just like a conductor ensures each instrument plays its part in a symphony, the container runtime guarantees each container contributes seamlessly to the overall health and functionality of your Kubernetes deployment.

## Conclusion

In summary, Kubernetes revolutionizes container orchestration, providing a scalable and efficient platform for deploying, scaling, and managing containerized applications. Its architecture, consisting of control plane and node components, ensures seamless coordination and automation across clusters. With Kubernetes, teams can optimize resource utilization, enhance agility, and drive innovation in software delivery pipelines, making it a cornerstone technology in modern DevOps practices.