How does Kubernetes keep thousands of containers running?
Kubernetes does not follow a recipe. It works like a thermostat, and its engineers named it "Project 7" after a Star Trek character who left the Borg.
▶ Start the storyKubernetes keeps containers running by never following a recipe. You tell it the state you want, such as three copies of a program, and independent control processes continuously drive the current state towards that desired state. The documentation explains it with a thermostat: you set the temperature, which is the desired state; the room temperature is the current state; and the thermostat turns equipment on or off to close the gap. Kubernetes does the same for containers, all day long.
Step 1: You declare the desired state
For example, three copies of a pod
Step 2: Controllers watch
They compare the current state with the desired state
Step 3: They fix the gap
Create a missing pod, replace a failed container
Step 4: Repeat forever
A non-terminating loop, like a thermostat
The machinery is straightforward. Kubernetes assembles computers into a that runs workloads in containers. The basic unit it deploys is the pod, one or more containers on the same . A scheduler picks the node for each new pod based on available resources, and you tell Kubernetes how much CPU and memory each container needs so it can fit them onto the machines efficiently.
When something breaks, the loop does the repair. If an operator asks for three instances and only two are running, the Deployment controller schedules another. Kubernetes restarts containers that fail and kills those that don't pass a health check. status arrives by every few seconds, and when a node fails, a controller launches its pods on another healthy node.
The idea came from inside Google. Kubernetes was inspired by Borg, Google's manager, which runs hundreds of thousands of jobs across clusters of up to tens of thousands of machines. Engineers who had worked on Borg codenamed the new project "Project 7" after Seven of Nine, a Star Trek character who left the Borg, and gave it a ship's wheel logo with seven spokes. Google announced it on 6 June 2014. The name is Greek for helmsman.
Quiz me
0/3
Recap
You declare the desired state, and controllers keep comparing it with the current state and fixing the gap, like a thermostat.
💡 A trick to remember it · A thermostat for containers: you set the number, and it keeps turning things on or off until the room matches.
Surprising fact · Its codename "Project 7" refers to Seven of Nine, a Star Trek character who left the Borg.
Connects to
- 🏗️ How can a whole data center be described in a text file?
- ⚖️ How does a website spread millions of visitors across machines?
- ⚡ What runs your code when there's no server to rent?
- 🔺 Why can't a system spread across the world be both always consistent and always available?
- 📦 Why did shipping software in containers change how it runs?
Sources (4)
No source, no claim. Every fact in this lesson (17 claims) cites at least one of these.