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!