Sub topic 1
The problem: running containers at scale
Prerequisites
This chapter assumes you can build and run a container image with a tool such as Docker, and that you are comfortable in a Linux shell. You should know what an IP address and a port are. You do not need to know any Kubernetes yet.
One container is easy
Running one container on one machine takes a single command:
docker run -d --name web -p 8080:80 nginx:1.27This works well for development. The trouble starts when the same application must run in production, for real users, on many machines.
What changes at scale
Once you run dozens or hundreds of containers across several hosts, you have to answer questions that docker run does not answer:
- Placement. Which host has enough free CPU and memory for this container?
- Failure. If a container crashes or a host dies at 3 a.m., who starts a replacement?
- Scaling. If traffic triples, who starts more copies, and who removes them afterward?
- Discovery. Containers get new IP addresses each time they start. How do other services find them?
- Load balancing. How is traffic spread across several identical copies?
- Updates. How do you ship a new image version without downtime, and roll back if it is broken?
- Configuration. How do you give each container its settings and credentials without baking them into the image?
You can solve these with shell scripts and a runbook. That approach works for a handful of servers. It becomes fragile as the number of containers and the number of people editing the scripts grow.
Orchestration
Container orchestration is software that automates these tasks across a group of machines. You tell it what you want to run, and it decides where to run it and keeps it running.
The key shift is from commands to goals. With a script, you say "start three containers on host A." With an orchestrator, you say "I want three copies of this container running," and the system works out the rest. If one copy dies, the orchestrator notices the gap and fills it.
Where Kubernetes fits
Kubernetes is the most widely used container orchestrator. The next chapters explain how it is built and why its design, a declared goal plus loops that keep reality matching it, handles the problems above. For now, remember the list of problems. Each part of Kubernetes exists to answer one or more of them.
Check your understanding
Exercise
A host running three of your containers loses power. Name two questions from the list above that an orchestrator answers in this situation, and say what it does for each.
Show answer
Failure: it notices the containers are gone and starts replacements. Placement: it picks other hosts with enough free CPU and memory for them. Discovery and load balancing are also valid, since traffic must stop going to the dead containers and reach the new ones.
Exercise
What is the difference between telling a script "start three containers on host A" and telling an orchestrator "I want three copies running"?
Show answer
The script describes steps and a fixed location, so nothing repairs the result if a container dies. The orchestrator is given a goal, so it chooses placement itself and keeps working to restore three copies whenever the count drops.