# Kubernetes Architecture ## Understanding Kubernetes Components ## 1. Overview A **Kubernetes cluster** is made up of multiple components that work together to deploy, manage, and scale containerized applications. At a high level, Kubernetes follows a **master–worker architecture**, where: - The **Control Plane** manages the cluster - The **Worker Nodes** run the applications (Pods) {/* TODO: Add E2E Kubernetes Cluster architecture diagram */} ## 2. High-Level Kubernetes Architecture A Kubernetes cluster consists of: - **Control Plane** — Responsible for decision-making and cluster state - **Worker Nodes** — Responsible for running application workloads ``` Kubernetes Cluster │ ├── Control Plane │ └── Worker Nodes (1 or more) ``` ## 3. Control Plane Components The **Control Plane** manages the overall state of the Kubernetes cluster. It makes global decisions such as: - Scheduling pods - Maintaining desired state - Handling failures - Managing cluster configuration ### 3.1 kube-apiserver **kube-apiserver** is the **central management component** of Kubernetes. **Key responsibilities:** - Exposes the Kubernetes REST/HTTP API - Acts as the **front-end** of the control plane - All communication (kubectl, controllers, nodes) goes through it - Validates and processes API requests ### 3.2 etcd **etcd** is a **distributed, consistent, and highly available key-value store**. **Key responsibilities:** - Stores the **entire cluster state** - Holds: - Pod definitions - ConfigMaps - Secrets - Node information - Acts as the **single source of truth** ### 3.3 kube-scheduler The **kube-scheduler** decides **where Pods should run**. **Key responsibilities:** - Watches for Pods without assigned nodes - Selects the best node based on: - CPU & memory availability - Affinity / anti-affinity rules - Taints and tolerations - Assigns the Pod to a node ### 3.4 kube-controller-manager The **kube-controller-manager** runs multiple controllers. Each controller continuously monitors the cluster and ensures the **desired state matches the actual state**. **Common controllers:** - Node Controller - ReplicaSet Controller - Deployment Controller - Job Controller - Endpoint Controller ### 3.5 cloud-controller-manager This component integrates Kubernetes with **cloud providers**. **Responsibilities:** - Manages cloud-specific resources: - Load balancers - Volumes - Node lifecycle - Allows Kubernetes to run consistently across clouds ## 4. Worker Node Components **Worker Nodes** are the machines where application workloads run. Each node contains components required to: - Run Pods - Communicate with the control plane - Handle networking and container execution ### 4.1 kubelet **kubelet** is the **node agent**. **Key responsibilities:** - Communicates with kube-apiserver - Ensures containers defined in Pods are running - Reports node and pod status - Performs health checks ### 4.2 kube-proxy **kube-proxy** handles **networking for Services**. **Key responsibilities:** - Maintains network rules on nodes - Enables Service-to-Pod communication - Implements load balancing using: - iptables or IPVS ### 4.3 Container Runtime The **container runtime** is responsible for **running containers**. **Examples:** - containerd - CRI-O **Responsibilities:** - Pull container images - Create and manage containers - Handle container lifecycle ---