Kubernetes Architecture: Control Planes, Pods, Services, and Zero-Downtime Deployments
Running a single container on a virtual machine using Docker is straightforward. However, when an application scales to dozens of microservices spanning hundreds of containers across multiple physical servers, manual management breaks down:
- What happens if a server crashes at 3 AM?
- How do you balance traffic across twenty replicas of an API?
- How do you deploy updates with zero downtime and roll back instantly if an error rate spikes?
- How do you scale container counts up and down dynamically in response to CPU load?
Kubernetes (often abbreviated as K8s), originated by Google and maintained by the Cloud Native Computing Foundation (CNCF), is the industry-standard container orchestration platform designed to automate deployment, scaling, healing, and operations of application containers.
1. Kubernetes Architecture: Control Plane & Worker Nodes
A Kubernetes cluster is divided into two distinct functional planes: the Control Plane (the cluster's brain) and Worker Nodes (where your containerized applications execute).
1┌────────────────────────────────────────────────────────────────────────┐2│ Control Plane (Master) │3│ │4│ [ kube-apiserver ] ◄── Authentication, Validation, & REST Gateway │5│ ▲ │ │6│ │ ▼ │7│ [ etcd ] ── Strongly consistent distributed state store │8│ ▲ │9│ ├────────────────────────────┬────────────────────────────┐ │10│ ▼ ▼ ▼ │11│ [ kube-scheduler ] [ kube-controller-mgr ] [ cloud-controller ] │12│ Assigns Pods to Nodes Maintains desired state Interfaces with AWS/ │13│ (Replication, Endpoints) GCP/Azure APIs │14└─────────────────────────────────────┬──────────────────────────────────┘15 │16 ┌───────────────────────┴───────────────────────┐17 ▼ Worker Node 1 ▼ Worker Node 218┌──────────────────────────────┐ ┌──────────────────────────────┐19│ [ kubelet ] │ │ [ kubelet ] │20│ Communicates with apiserver │ │ Communicates with apiserver │21│ Ensures Pods are running │ │ Ensures Pods are running │22│ │ │ │23│ [ kube-proxy ] │ │ [ kube-proxy ] │24│ Manages network IP routing │ │ Manages network IP routing │25│ │ │ │26│ [ containerd (CRI) ] │ │ [ containerd (CRI) ] │27│ Executes container runtime │ │ Executes container runtime │28│ │ │ │29│ ┌────────────────────────┐ │ │ ┌────────────────────────┐ │30│ │ Pod A (App Container) │ │ │ │ Pod B (App Container) │ │31│ └────────────────────────┘ │ │ └────────────────────────┘ │32└──────────────────────────────┘ └──────────────────────────────┘
Control Plane Components:
kube-apiserver: The central communication hub. Every administrative tool (kubectl) and node daemon communicates exclusively through this REST API.etcd: A highly available, distributed key-value store that holds the complete canonical state of the cluster.kube-scheduler: Watches for newly created Pods without assigned nodes and selects the optimal worker node based on resource requests, taints, and affinities.kube-controller-manager: Runs continuous reconciliation control loops (e.g., comparing current replica counts against the desired specification and launching replacements when nodes die).
Worker Node Components:
kubelet: The node agent that registers the node with the control plane and ensures the containers described in assignedPodSpecmanifests are healthy.kube-proxy: Manages low-level host networking and packet filtering rules (usingiptablesorIPVS) to route traffic to Pods across the cluster.- Container Runtime (
containerd/CRI-O): Pulls images and runs the underlying Linux container processes.
2. Core Kubernetes Objects
Kubernetes manages infrastructure declaratively through YAML manifests. You define the desired state, and Kubernetes continuously works to achieve that state.
1. The Pod
The smallest deployable computing unit in Kubernetes. A Pod encapsulates one or more closely coupled containers that share:
- A single network namespace (same IP address and port space).
- Shared storage volumes.
- IPC (Inter-Process Communication).
2. Deployments & ReplicaSets
Pods are ephemeral: their IP addresses change when recreated, and they do not restart automatically if their host node dies. A Deployment manages a ReplicaSet, ensuring that a specified number of identical Pod replicas remain running across your cluster at all times:
1# deployment.yaml2apiVersion: apps/v13kind: Deployment4metadata:5 name: api-service6 labels:7 app: api-service8spec:9 replicas: 310 selector:11 matchLabels:12 app: api-service13 strategy:14 type: RollingUpdate15 rollingUpdate:16 maxSurge: 1 # Allow 1 extra Pod during deployments17 maxUnavailable: 0 # Zero downtime: never drop below 3 replicas!18 template:19 metadata:20 labels:21 app: api-service22 spec:23 containers:24 - name: api25 image: myregistry.io/api-service:v2.1.026 imagePullPolicy: IfNotPresent27 ports:28 - containerPort: 300029 resources:30 requests:31 memory: "128Mi"32 cpu: "100m" # 0.1 CPU core33 limits:34 memory: "512Mi"35 cpu: "500m" # 0.5 CPU core36 livenessProbe:37 httpGet:38 path: /api/health/liveness39 port: 300040 initialDelaySeconds: 1041 periodSeconds: 1042 readinessProbe:43 httpGet:44 path: /api/health/readiness45 port: 300046 initialDelaySeconds: 547 periodSeconds: 5
3. Services: Stable Networking for Ephemeral Pods
Because Pods can be destroyed, rescheduled, and assigned dynamic IP addresses at any time, other services cannot rely on static Pod IPs.
A Service provides an invariant virtual IP address (ClusterIP) and an internal DNS entry that automatically balances incoming requests across all matching Pods:
1# service.yaml2apiVersion: v13kind: Service4metadata:5 name: api-service6spec:7 type: ClusterIP # Internal cluster communication8 selector:9 app: api-service # Directs traffic to Pods matching this label10 ports:11 - name: http12 port: 80 # Service port accessible to other cluster pods13 targetPort: 3000 # Target port on the container
Other applications inside the cluster can now send HTTP traffic directly to http://api-service with automatic round-robin load balancing.
4. Health Probes: Self-Healing Architecture
Kubernetes uses three distinct health probes to maintain system resilience:
1┌────────────────────────────────────────────────────────┐2│ Health Probes │3├─────────────────┬──────────────────────────────────────┤4│ Probe Type │ Action on Failure │5├─────────────────┼──────────────────────────────────────┤6│ Startup Probe │ Pauses liveness checks while booting │7│ Liveness Probe │ Kills and restarts frozen containers │8│ Readiness Probe │ Temporarily removes from Service IP │9└─────────────────┴──────────────────────────────────────┘
- Liveness Probe: Detects deadlocks where a container is technically still running as a process but incapable of making progress. When it fails, the
kubeletterminates and restarts the container. - Readiness Probe: Detects when an application is temporarily overloaded or warming up its internal database cache. When it fails, Kubernetes stops sending traffic to that specific Pod until it reports ready, preventing failed user requests.
5. Ingress: Layer 7 Routing
While a Service handles internal routing, an Ingress acts as the cluster's reverse proxy and API Gateway, handling SSL termination, domain routing, and path-based dispatching:
1# ingress.yaml2apiVersion: networking.k8s.io/v13kind: Ingress4metadata:5 name: app-ingress6 annotations:7 cert-manager.io/cluster-issuer: "letsencrypt-prod"8spec:9 ingressClassName: nginx10 tls:11 - hosts:12 - api.mycompany.com13 secretName: api-tls-cert14 rules:15 - host: api.mycompany.com16 http:17 paths:18 - path: /19 pathType: Prefix20 backend:21 service:22 name: api-service23 port:24 number: 80
6. When to Use Kubernetes vs. Simpler Alternatives
| Infrastructure Choice | When to Use | Trade-offs |
|---|---|---|
| Vercel / Cloudflare | Next.js, static sites, Edge APIs | Zero infrastructure management; limited long-running processes |
| AWS ECS / GCP Cloud Run | Dockerized web apps, microservices | Managed control plane, pay-per-use, lower operational complexity |
| Kubernetes (EKS / GKE) | Large fleets, multi-cloud, microservices, complex networks | Maximum control and customizability; high operational complexity |
7. Summary
Kubernetes is the standard operating system of cloud infrastructure:
- Declarative manifests ensure clusters continuously self-heal toward the desired state.
- Deployments orchestrate rolling updates with zero downtime.
- Services and Ingresses solve dynamic routing across ephemeral container lifecycles.
- Liveness and Readiness probes protect user experiences by isolating degraded pods.
