Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It has become the standard for container orchestration and is used by organizations worldwide to manage microservices applications efficiently. In this blog, we will explore the core components of the Kubernetes architecture and understand how they work together to provide a robust and scalable container management solution.
Kubernetes Architecture Overview
Kubernetes follows a master-slave architecture consisting of a master node (or control plane) and multiple worker nodes. Each node in the cluster runs containers, but the roles of the master and worker nodes are distinct.
Key Components of Kubernetes
1. Master Node (Control Plane)
The master node is the brain of the Kubernetes cluster. It manages the Kubernetes cluster's state and makes global decisions about the cluster (for example, scheduling, scaling, and updating). It consists of several key components:
a. API Server (kube-apiserver)
The API server is the entry point for all REST commands used to interact with the cluster. It's the central control point that exposes the Kubernetes API and serves the HTTP API used by clients (including kubectl
), the control plane components, and other internal components.
Key command to interact with the API Server:
kubectl cluster-info
b. Controller Manager (kube-controller-manager)
This component runs controllers that handle routine tasks like managing nodes, pods, and deployments. It ensures that the desired state of the cluster matches the actual state by managing tasks such as replication, scaling, and node health.
Key command to view controller logs:
kubectl logs -n kube-system <controller-pod-name>
c. Scheduler (kube-scheduler)
The scheduler is responsible for selecting the nodes where newly created pods will run. It watches for newly created pods and places them on the best available node based on resource requirements, constraints, and policies.
Key command to get scheduler information:
kubectl get pods --namespace=kube-system
d. etcd (etcd cluster)
etcd
is a consistent and highly-available key-value store that holds all cluster data, including configurations, states, and secrets. It serves as the source of truth for the entire cluster. The etcd cluster stores Kubernetes’ state, so if the cluster's state needs to be restored, it’s retrieved from etcd
.
Key command to interact with etcd:
kubectl get secrets --namespace=kube-system
2. Worker Node
Worker nodes are where the application workloads (containers) run. A Kubernetes cluster can have multiple worker nodes, and each worker node contains several components to run and manage containers.
a. Kubelet
The kubelet is an agent that runs on each worker node in the cluster. It ensures that containers are running in the pods, as specified by the controller manager. It also communicates with the API server to report the node’s health and status.
Key command to view node status:
kubectl get nodes
b. Kube Proxy
Kube Proxy maintains network rules across the nodes to allow communication between pods and services. It can implement rules such as load balancing and service discovery. Kube Proxy ensures that services are accessible by exposing a single IP address and port.
Key command to get the proxy status:
kubectl get pod -n kube-system -l k8s-app=kube-proxy
c. Container Runtime
The container runtime is responsible for pulling container images from a container registry and running containers. Kubernetes supports different container runtimes such as Docker, containerd, and CRI-O. Docker has historically been the default runtime, but Kubernetes is moving towards using containerd and CRI-O.
Key command to view container runtime information:
kubectl describe node <node-name>
3. Pods and Containers
A pod is the smallest deployable unit in Kubernetes, which can contain one or more containers. Each container in a pod shares the same network namespace, meaning they can communicate with each other using localhost.
Key command to list pods:
kubectl get pods
Key command to get details about a specific pod:
kubectl describe pod <pod-name>
4. Services
A service in Kubernetes provides a stable IP address and DNS name for a set of pods, enabling load balancing and service discovery. Kubernetes supports different types of services like ClusterIP (default), NodePort, LoadBalancer, and ExternalName, allowing flexible access patterns.
Key command to list services:
kubectl get svc
Key command to expose a service:
kubectl expose pod <pod-name> --type=NodePort --name=<service-name>
How Kubernetes Works Together
Kube API Server handles all requests and validates them before they are accepted. It is the central hub for communication.
Controllers and Scheduler decide where to place workloads (pods), scale services, and ensure the cluster is running as expected.
Kubelet ensures that each node runs the necessary containers and manages their health.
Kube Proxy makes sure that communication between pods, nodes, and services is seamless and reliable.
Thank You for Reading :)
Ramya R