How Kubernetes Works: The Container Orchestrator
Docker runs containers. Kubernetes manages them. We explain Pods, Nodes, Deployments, and Services to demystify the world's most popular orchestrator.
Abstract AlgorithmsTLDR: Kubernetes (K8s) is an operating system for the cloud. It manages clusters of computers (Nodes) and schedules applications (Pods) onto them. It handles self-healing (restarting crashed apps), scaling (adding more copies), and networking via a continuous declarative control loop.
๐ The Shipping Port Manager Analogy
Before Kubernetes, deploying an app meant SSH-ing into servers and running commands manually. If a server died, so did your app.
Kubernetes introduces a Shipping Port Manager model:
- Container (Docker image): A shipping container โ standardized, portable.
- Pod: A crane holding one or more containers together on the same network.
- Node: A cargo ship (server) that carries Pods.
- Control Plane: The manager in the tower. She says "put 3 cranes on Ship A." If Ship A sinks, she moves them to Ship B.
You never talk to ships directly. You talk to the manager.
๐ข Nodes, Pods, and Deployments: The Object Hierarchy
Pod (The Atom)
The smallest schedulable unit. Usually runs one container (your app). Sometimes includes sidecar containers โ helpers that share the same IP and disk (e.g., log forwarders, service mesh proxies).
Node (The Worker Machine)
A physical or virtual machine running the Pods. Each Node runs:
- kubelet โ the agent that talks to the Control Plane.
- kube-proxy โ handles network rules.
- Container runtime (Docker, containerd).
Deployment (The Blueprint)
You don't create Pods directly. You write a Deployment:
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
spec:
containers:
- name: nginx
image: nginx:1.25
K8s creates 3 Pods. If one dies, K8s creates a replacement automatically.
Service (The Stable Phone Number)
Pods die and change IPs. A Service gives a stable virtual IP to a set of Pods.
flowchart TD
User --> Service["Service\n(ClusterIP: 10.0.0.5)"]
Service --> Pod1["Pod 1"]
Service --> Pod2["Pod 2"]
Service --> Pod3["Pod 3"]
The Service load-balances incoming traffic across all healthy Pods โ even as Pods restart and get new IPs.
โ๏ธ The Control Loop: Desired State โ Current State โ Reconcile
This is the core mechanism behind everything Kubernetes does.
flowchart LR
YAML["Desired State\n(replicas: 3)"] --> CP["Control Plane\n(kube-controller-manager)"]
CP --> Check["Observe Current State\n(replicas: 2 โ one crashed)"]
Check --> Act["Reconcile:\nStart 1 new Pod"]
Act --> CP
The loop never stops. Every few seconds:
- Read the desired state from etcd (the cluster database).
- Observe the current state (running Pods, health checks).
- If they differ โ act (start, stop, or reschedule Pods).
This is why Kubernetes is called declarative: you describe what you want, not how to do it. K8s figures out the "how."
๐ง Services, ConfigMaps, and the Network Model
ConfigMaps and Secrets
Decouple configuration from container images:
| Resource | Purpose | Example |
| ConfigMap | Non-sensitive config | DATABASE_URL=postgres://... |
| Secret | Sensitive credentials | API_KEY=abc123 (base64-encoded) |
| PersistentVolume | Durable disk storage | Database data directories |
Networking
Every Pod gets a unique cluster-internal IP. Pods talk to each other via Service DNS names:
http://payment-service.default.svc.cluster.local:8080
No hardcoded IPs. The DNS name resolves to the Service's virtual IP, which load-balances to healthy Pods.
โ๏ธ When Kubernetes Is Overkill
| Context | Use Kubernetes | Use Something Simpler |
| 10+ microservices needing auto-scaling | โ | โ |
| Self-healing across node failures required | โ | โ |
| Single-service app with steady traffic | โ | Docker Compose or a single VM |
| Small team, no K8s expertise | โ | PaaS (Heroku, Railway, Fly.io) |
| Serverless workloads | โ | Lambda / Cloud Run |
The real cost of Kubernetes is operational complexity: certificates, RBAC, networking policies, pod disruption budgets, and cluster upgrades. Size your investment to your scale.
๐ Summary
- Pods wrap containers and are the atomic unit of scheduling.
- Deployments declare desired replica count. K8s maintains it continuously.
- Services give stable IPs to ephemeral Pods and load-balance traffic.
- The Control Loop: desired state โ observe current state โ reconcile. This never stops.
- etcd is the cluster's source of truth โ all desired state is stored there.
๐ Practice Quiz
You set
replicas: 3in a Deployment and one Pod crashes. What does Kubernetes do?- A) Alerts an on-call engineer.
- B) Starts a new Pod automatically to reach the desired count of 3.
- C) Waits for you to restart it manually.
Answer: B
Why don't you connect to Pods directly by IP?
- A) Pod IPs are external-only.
- B) Pods are ephemeral and change IPs when restarted; a Service provides a stable endpoint.
- C) K8s encrypts Pod IPs.
Answer: B
What is
etcdin a Kubernetes cluster?- A) A container runtime.
- B) A distributed key-value store that holds the desired state of the cluster.
- C) A load balancer for Services.
Answer: B

Written by
Abstract Algorithms
@abstractalgorithms
More Posts
SFT for LLMs: A Practical Guide to Supervised Fine-Tuning
TLDR: Supervised fine-tuning (SFT) is the stage where a pretrained model learns task-specific response behavior from curated input-output examples. It is usually the first alignment step after pretraining and often the foundation for later RLHF. Good...
RLHF in Practice: From Human Preferences to Better LLM Policies
TLDR: Reinforcement Learning from Human Feedback (RLHF) helps align language models with human preferences after pretraining and SFT. The typical pipeline is: collect preference comparisons, train a reward model, then optimize a policy (often with KL...
PEFT, LoRA, and QLoRA: A Practical Guide to Efficient LLM Fine-Tuning
TLDR: Full fine-tuning updates every model weight, which is expensive in memory, compute, and storage. PEFT methods update only a small trainable slice. LoRA learns low-rank adapters on top of frozen base weights. QLoRA pushes efficiency further by q...
LLM Model Naming Conventions: How to Read Names and Why They Matter
TLDR: LLM names encode practical decisions: model family, size, training stage, context window, format, and quantization level. If you can decode naming conventions, you can avoid costly deployment mistakes and choose the right checkpoint faster. ๏ฟฝ...
