Docker runs containers on one machine. Kubernetes (K8s) runs them across many machines and keeps them in the state you asked for – restarting crashed containers, spreading load and rolling out updates. If your company runs containers in production, it’s very likely on Kubernetes (often a managed service like AKS, EKS or GKE).
Lab: try it locally with kind, minikube or Docker Desktop’s built-in Kubernetes.
The big idea: desired state
You don’t tell Kubernetes “start 3 containers”. You declare “there should always be 3 replicas of this app” in a YAML file, and Kubernetes continuously works to make reality match – like a very fast, very persistent admin.
Building blocks
| Object | What it is | Rough infra equivalent |
|---|---|---|
| Cluster | Control plane + worker nodes | The whole platform |
| Node | A worker machine (VM) | A server |
| Pod | One or more containers that run together, the smallest unit | A process group |
| Deployment | Keeps N identical pods running; handles rolling updates | A scaled service |
| Service | Stable name and IP that load-balances to pods | A virtual IP / load balancer |
| Ingress | HTTP(S) routing from outside to services | A reverse proxy |
| ConfigMap / Secret | Config and sensitive values for pods | Config files / credentials |
| PersistentVolume(Claim) | Storage that outlives pods | A disk / LUN |
| Namespace | A logical partition of the cluster | A folder / environment |
A minimal app
demo.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-web
spec:
replicas: 3
selector:
matchLabels: { app: demo-web }
template:
metadata:
labels: { app: demo-web }
spec:
containers:
- name: web
image: nginx:1.27
ports: [{ containerPort: 80 }]
resources:
requests: { cpu: 100m, memory: 64Mi }
limits: { memory: 128Mi }
readinessProbe:
httpGet: { path: /, port: 80 }
---
apiVersion: v1
kind: Service
metadata:
name: demo-web
spec:
selector: { app: demo-web }
ports: [{ port: 80, targetPort: 80 }]
kubectl apply -f demo.yaml
kubectl get deploy,pods,svc
kubectl delete pod <one-pod-name> # watch Kubernetes replace it immediately
kubectl scale deploy demo-web --replicas=5
kubectl for troubleshooting
kubectl get pods -A # everything, all namespaces
kubectl get pods -n myapp -o wide # which node each pod runs on
kubectl describe pod <pod> # events: scheduling, image pulls, probe failures
kubectl logs <pod> # container logs
kubectl logs <pod> --previous # logs from the crashed previous run
kubectl exec -it <pod> -- sh # shell inside the container
kubectl get events -n myapp --sort-by=.lastTimestamp
kubectl top pods -n myapp # CPU/memory (needs metrics-server)
Common pod states:
| Status | Usual cause |
|---|---|
| Pending | No node has enough CPU/memory, or a volume can’t attach |
| ImagePullBackOff | Wrong image name/tag, or no credentials for the registry |
| CrashLoopBackOff | The app starts and crashes – check logs --previous |
| Running but not Ready | Readiness probe failing – app not healthy yet |
| OOMKilled | Container exceeded its memory limit |
Why ops skills still matter
Kubernetes automates a lot, but someone still has to understand networking, DNS, storage, certificates, monitoring, capacity and security – the same fundamentals as the rest of this site, applied to a new platform.
FAQ
Do I need Kubernetes for a few internal apps? Usually not – Docker Compose or plain VMs are simpler. Kubernetes pays off when you run many services that need scaling and frequent deployments.
What’s next
Next: Terraform basics – infrastructure as code.
Practise this topic
Test yourself with free questions on this topic – instant answers and explanations.
Start practice questionsKubernetesContainersDevOpsAdvanced