A system that runs, scales, heals and updates your containers across many machines.
Kubernetes (often written K8s) is a system that runs your containers across many machines and keeps them healthy for you.
A single container is easy to run. Running hundreds of containers on dozens of machines is not. Something must decide which machine runs which container, restart the ones that crash, give them addresses, update them without downtime and add more when traffic grows. That job is called container orchestration, and Kubernetes is the most widely used orchestrator.
The big idea is the reconciliation loop. You send Kubernetes a description of what you want (a YAML file). A group of controllers then watch the cluster all the time. Each one asks: "does reality match what was asked for?" If not, it acts. Because this loop never stops, the cluster heals itself.
| Object | What it is | Why it exists |
|---|---|---|
| Pod | The smallest unit. One or more containers that share a network address and storage. | Pods are short-lived. Never rely on a single pod's IP address. |
| ReplicaSet | Keeps a chosen number of identical pods running. | Gives self-healing. You rarely create one by hand. |
| Deployment | Manages ReplicaSets for you and does rolling updates and rollbacks. | The normal way to run a stateless app. |
| Service | A stable name and virtual IP that spreads traffic over the ready pods behind it. | Pods change, so clients need one steady address. |
| Ingress | Rules that route outside HTTP traffic (by host or path) to Services. | One entry point for many apps. |
| ConfigMap and Secret | Settings and sensitive values kept outside the image. | One image can run in dev, test and production. |
| StatefulSet and volumes | Pods with a steady identity and storage that survives restarts. | Databases and other apps that must remember data. |
| Namespace | A named group of objects inside a cluster. | Separate teams or environments, with their own limits. |
apiVersion: apps/v1
kind: Deployment
metadata:
name: shop-web
spec:
replicas: 3 # desired number of pods
selector:
matchLabels: { app: shop-web }
template:
metadata:
labels: { app: shop-web }
spec:
containers:
- name: web
image: example/shop-web:1.2
resources:
requests: { cpu: "250m", memory: "256Mi" }
limits: { memory: "512Mi" }
readinessProbe:
httpGet: { path: /ready, port: 8080 }You apply it with a command such as kubectl apply -f deployment.yaml. Field names and defaults can change between versions, so check the current Kubernetes documentation before you copy it.
A simplified model with no random numbers. Real Kubernetes also looks at CPU and memory requests when it places a pod, waits before it gives up on a node, and runs many controllers side by side. Here the controller does one thing per step, and a rolling update adds at most one extra pod at a time and never drops below the desired number of ready pods.
| Term | Meaning in easy words |
|---|---|
| Cluster | A set of machines (nodes) managed together by Kubernetes |
| Node | One worker machine that runs pods |
| Pod | The smallest unit: one or more containers sharing a network address and storage |
| Deployment | An object that keeps a number of pods running and handles rolling updates |
| Service | A stable name and address that balances traffic over a set of pods |
| Desired state | What you asked for, written in a manifest |
| Reconciliation loop | A controller repeatedly comparing actual state to desired state and fixing the difference |
| Readiness probe | A check that decides whether a pod should receive traffic |
| Liveness probe | A check that decides whether a pod is stuck and must be restarted |
| Resource request and limit | The amount reserved for scheduling, and the cap enforced while running |
| Manifest | A YAML (or JSON) file that describes objects you want |
| Choice | We gain | We lose |
|---|---|---|
| Kubernetes vs plain servers | Automation, healing, standard tooling | Simplicity, and a team that must learn it |
| Managed vs self-run control plane | Less work and fewer outages of the brain | Some control, and a cloud bill |
| Many small pods vs few big pods | Smoother scaling and failure impact | More overhead and more to manage |
| Tight CPU and memory limits | Fair sharing and a safer cluster | Throttling or killed containers if set too low |
| Autoscaling on | Pay for what you need | Slow reaction to sudden spikes, and tuning work |
| Running databases in the cluster | One platform for everything | Harder storage, backups and failover |