Docker packages an application into a container. But what do you do when you have hundreds of containers, they keep crashing, load spikes unpredictably, and a single server can no longer cope?
The Problem: Docker Compose on a Single Server
Docker Compose is great for local development and small projects. But it has hard limits:
- Runs on a single host only
- When the server goes down, the entire application is unavailable
- No automatic scaling under load
- Zero-downtime updates require custom scripting
- No built-in monitoring or self-healing
As an application grows, these limitations become critical.
What Is Kubernetes
Kubernetes (K8s) is an open-source container orchestrator originally created at Google. It automatically manages the deployment, scaling, and health of containerized applications across a cluster of servers.
Analogy: if Docker is a shipping container, Kubernetes is the port terminal with cranes, a schedule, and a dispatcher. It decides where to place each container, monitors its state, and replaces damaged ones.
Key Capabilities
Self-healing โ if a container crashes, K8s restarts it automatically. If a cluster node fails, pods migrate to healthy nodes.
Auto-scaling โ HorizontalPodAutoscaler increases the replica count when load rises and shrinks it when load drops.
Rolling updates โ updates with zero downtime: new pods come up while old ones shut down gradually. On error, automatic rollback kicks in.
Multi-node โ a cluster of multiple servers. Load is distributed across all nodes; no single point of failure.
Declarative configuration โ you describe the desired state in YAML; K8s converges the system to that state and keeps it there.
When to Use K8s vs Docker Compose
| Criterion | Docker Compose | Kubernetes |
|---|---|---|
| Team size | 1โ5 people | 5+ people |
| Servers | 1 | 3+ |
| Load | Stable | Variable |
| Availability requirement | None | 99.9%+ |
| Complexity | Low | High |
Use Docker Compose for startups, pet projects, or staging environments. Use Kubernetes when fault tolerance, scaling, and production-grade CI/CD matter.
Cluster Architecture
A K8s cluster has two types of nodes: Control Plane (the management layer) and Worker Nodes (where your workloads run).
Control Plane
The brain of the cluster. Makes scheduling decisions and is responsible for system state.
- API Server โ the single entry point. Every
kubectlcommand goes here. A REST API that accepts and validates requests. - etcd โ a distributed key-value store. All cluster state lives here. The most critical component โ lose etcd, lose the cluster.
- Scheduler โ decides which Worker Node to run a new Pod on, considering available resources, affinity rules, and constraints.
- Controller Manager โ a collection of controllers that watch current state and drive it toward the desired state (ReplicaSet, Deployment, Node controllers).
Worker Nodes
The workhorses. This is where your application containers actually run.
- kubelet โ an agent on every node. Receives assignments from the API Server and manages pods through the container runtime.
- kube-proxy โ a network proxy. Maintains network rules and load balancing inside the cluster.
- Container Runtime โ the engine that actually runs containers (containerd, CRI-O).
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Control Plane โ
โ API Server โ kubectl โ
โ etcd (state storage) โ
โ Scheduler โ
โ Controller Manager โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโผโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโ โโโโโโโโโ โโโโโโโโโ
โNode 1 โ โNode 2 โ โNode 3 โ
โkubeletโ โkubeletโ โkubeletโ
โ Pod โ โ Pod โ โ Pod โ
โ Pod โ โ Pod โ โ โ
โโโโโโโโโ โโโโโโโโโ โโโโโโโโโ
First Step: Installing kubectl
# macOS
brew install kubectl
# Verify connection to the cluster
kubectl cluster-info
kubectl get nodes
For a local cluster use minikube or kind:
# Install and start minikube
brew install minikube
minikube start
# Verify
kubectl get nodes
# NAME STATUS ROLES AGE VERSION
# minikube Ready control-plane 1m v1.29.0
Kubernetes is not just a tool โ it is a platform. The complexity is justified only when your workload genuinely requires orchestration.
๐ฌ Comments (0)
No comments yet
Be the first to share your opinion about this article!