Quick answer: Kubernetes (K8s) is a platform that runs and manages containers across many servers. You describe the desired state in YAML β for example "run 3 copies of my API image" β and Kubernetes keeps it that way: restarting crashed containers, spreading load, rolling out updates and scaling. The core objects you must know are Pod, Deployment, Service, Ingress, ConfigMap, Secret and Namespace.
Docker runs containers on one machine. Kubernetes runs them reliably across a cluster of machines. It is the standard behind managed services such as Amazon EKS, Azure AKS and Google GKE, and one of the most requested skills for DevOps and cloud roles.
Architecture in one picture
ββββββββββββ Control plane ββββββββββββ
kubectl βββΊ β API server Β· scheduler Β· controllers β βββ etcd (cluster state)
ββββββββββββββββββββ¬ββββββββββββββββββββ
β
ββββββββββ Worker node ββββββββββ βββββ Worker node βββββ
β kubelet Β· container runtime β β kubelet Β· runtime β
β [Pod] [Pod] [Pod] β β [Pod] [Pod] β
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββCore objects
Object | What it does |
|---|---|
Pod | Smallest unit; one (or a few tightly coupled) containers sharing network and storage |
Deployment | Keeps N replicas of a Pod running; handles rolling updates and rollbacks |
Service | Stable internal address and load balancing for a set of Pods |
Ingress / Gateway | HTTP(S) routing from outside the cluster (domains, paths, TLS) |
ConfigMap | Non-secret configuration |
Secret | Sensitive values (encode β encrypt β enable encryption at rest or use an external secrets manager) |
Namespace | Logical separation (dev, staging, team-a) |
StatefulSet | For stateful apps needing stable identity and storage |
Job / CronJob | Run-to-completion and scheduled tasks |
HorizontalPodAutoscaler | Scales replicas based on CPU, memory or custom metrics |
A complete minimal example
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders-api
spec:
replicas: 3
selector:
matchLabels: { app: orders-api }
template:
metadata:
labels: { app: orders-api }
spec:
containers:
- name: api
image: registry.example.com/orders-api:1.4.2
ports: [{ containerPort: 8080 }]
envFrom:
- configMapRef: { name: orders-config }
- secretRef: { name: orders-secrets }
resources:
requests: { cpu: "100m", memory: "256Mi" }
limits: { memory: "512Mi" }
readinessProbe:
httpGet: { path: /health/ready, port: 8080 }
livenessProbe:
httpGet: { path: /health/live, port: 8080 }
---
apiVersion: v1
kind: Service
metadata:
name: orders-api
spec:
selector: { app: orders-api }
ports: [{ port: 80, targetPort: 8080 }]Essential kubectl commands
kubectl apply -f k8s/ # create/update from files
kubectl get pods -n prod -o wide
kubectl describe pod <name> # events and errors
kubectl logs -f deploy/orders-api
kubectl exec -it <pod> -- sh
kubectl rollout status deploy/orders-api
kubectl rollout undo deploy/orders-api # rollback
kubectl scale deploy/orders-api --replicas=5
kubectl port-forward svc/orders-api 8080:80Troubleshooting common errors
- ImagePullBackOff β wrong image name/tag or missing registry credentials.
- CrashLoopBackOff β app starts then exits; check
kubectl logs --previous. - Pending β not enough CPU/memory on nodes, or a volume cannot attach.
- OOMKilled β memory limit too low or a memory leak.
- Service not reachable β labels in selector do not match Pod labels.
Production best practices
- Always set resource requests (and memory limits).
- Add readiness and liveness probes.
- Run at least 2β3 replicas and use PodDisruptionBudgets.
- Use immutable image tags (versions or digests), never
latest. - Apply RBAC with least privilege and NetworkPolicies.
- Run containers as non-root with read-only file systems where possible.
- Manage manifests with Helm or Kustomize and deploy via GitOps (Argo CD, Flux).
- Centralise logs, metrics and traces (Prometheus, Grafana, OpenTelemetry).
Do you even need Kubernetes?
For a single app or small team, simpler options like AWS ECS/App Runner, Azure Container Apps, Google Cloud Run or a PaaS may be cheaper and easier. Kubernetes shines when you run many services, need portability across clouds, or have a platform team.
Learning path
- Docker basics β 2. Local cluster with kind, minikube or k3d β 3. Deploy an app with Deployment + Service + Ingress β 4. ConfigMaps, Secrets, probes β 5. Helm and GitOps β 6. Managed cluster on a cloud β 7. Certifications: CKAD, CKA, CKS.
Summary
- Kubernetes keeps your declared desired state running.
- Learn Pod, Deployment, Service, Ingress, ConfigMap, Secret first.
- Requests, probes, replicas and RBAC are non-negotiable in production.
- Choose simpler platforms when K8s is overkill.