Labs ICT
⭐ Pro Login

Kubernetes Architecture

Control plane, nodes, and how Kubernetes works under the hood

Kubernetes Architecture

Understanding Kubernetes architecture is crucial for working with it effectively. A Kubernetes cluster consists of a control plane and one or more worker nodes.

Cluster Overview


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                    Control Plane                         β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
  β”‚  β”‚   API    β”‚  β”‚ Scheduler β”‚  β”‚Controllerβ”‚  β”‚  etcd  β”‚ β”‚
  β”‚  β”‚  Server  β”‚  β”‚           β”‚  β”‚ Manager  β”‚  β”‚        β”‚ β”‚
  β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”˜
          β”‚              β”‚              β”‚            β”‚
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”
  β”‚       β”‚          Worker Nodes       β”‚            β”‚      β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”          β”‚
  β”‚  β”‚   kube   β”‚  β”‚   kube    β”‚  β”‚   kube   β”‚          β”‚
  β”‚  β”‚  -proxy  β”‚  β”‚  -proxy   β”‚  β”‚  -proxy  β”‚          β”‚
  β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜          β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”          β”‚
  β”‚  β”‚Container β”‚  β”‚Container  β”‚  β”‚Container β”‚          β”‚
  β”‚  β”‚ Runtime  β”‚  β”‚ Runtime   β”‚  β”‚ Runtime  β”‚          β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Control Plane Components

API Server (kube-apiserver) β€” The front door to the cluster. All communication between components goes through the API server. kubectl talks to the API server.

etcd β€” A distributed key-value store that holds all cluster state. Think of it as the cluster's database. Without etcd, Kubernetes has no memory.

Scheduler (kube-scheduler) β€” Watches for newly created pods with no assigned node and selects a node for them to run on based on resource requirements and constraints.

Controller Manager (kube-controller-manager) β€” Runs controller loops that regulate the state of the system. For example, the ReplicaSet controller ensures the desired number of pods are always running.

Worker Node Components

kubelet β€” An agent running on each node that ensures containers are running in a pod. It communicates with the container runtime to start, stop, and monitor containers.

kube-proxy β€” Maintains network rules on nodes, enabling Services to route traffic to the correct pods.

Container Runtime β€” The software responsible for running containers. Common runtimes include containerd, CRI-O, and Docker (deprecated).

How a Deployment Works


  1. You run: kubectl apply -f deployment.yaml
        β”‚
        β–Ό
  2. API Server stores the desired state in etcd
        β”‚
        β–Ό
  3. Controller Manager notices the new Deployment
     and creates a ReplicaSet
        β”‚
        β–Ό
  4. Scheduler assigns the ReplicaSet's Pods to nodes
        β”‚
        β–Ό
  5. Kubelet on each node tells the container runtime
     to start the containers
        β”‚
        β–Ό
  6. Everything is now running! K8s continuously
     reconciles desired vs actual state