Why Use Kubernetes?
The notes app has grown. It needs three copies of the web server, updates twice a week without downtime, and a database that must survive a crashed machine. You could write scripts for each of these. Kubernetes exists so that you do not have to.
The rule
Kubernetes turns chores you would script into promises the cluster keeps.
Each chore below is something a team would otherwise do by hand or with custom scripts. In Kubernetes it becomes one line of configuration:
| Chore | What Kubernetes gives you |
|---|---|
| Restart crashed apps | Self-healing: failed containers are restarted, lost copies replaced |
| Add copies at busy times | Scaling: change replicas, or let an autoscaler do it |
| Ship a new version safely | Rolling updates that swap copies gradually, with undo |
| Find the other services | Service discovery: a stable name like notes-db |
| Spread traffic | Load balancing across healthy copies |
| Fit apps onto machines | Scheduling that packs work onto nodes with room |
Scaling our web tier is a single command:
kubectl scale deployment notes-web --replicas=5The same manifests also run on a laptop, in a company data centre, or on any major cloud, so you are less tied to one provider.
Kubernetes is not free, though. It has many moving parts, a vocabulary to learn, and a cluster to keep healthy. A single small app with little traffic on one server may be happier with something simpler.
The shortcut
Count the chores. If you would otherwise write scripts for several of them, Kubernetes pays for itself. If you need none of them, it is overhead.
List the needs
Three web copies, updates without downtime, restart on crash, a database that keeps its data.
The trap is adopting Kubernetes because it is popular. A weekend project with one container and no uptime promise gains little and pays the full learning cost.
Drills
Answer fast — trust the rule.
A notes-web container crashes. Which Kubernetes feature brings it back?
Which command raises the notes-web Deployment to five copies?
The web tier needs to reach the database without hard-coding an IP address. Which feature helps?
Which situation gains the least from Kubernetes?
Remember
- Kubernetes turns chores you would script into promises the cluster keeps.
- Count the chores: several needed means it pays; none means overhead.
- Trap: adopting it for fashion when one server would do.
