Tech●●●●●Difficulty 4 of 5

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 story

Kubernetes 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.

The Kubernetes control loop
  1. Step 1: You declare the desired state

    For example, three copies of a pod

  2. Step 2: Controllers watch

    They compare the current state with the desired state

  3. Step 3: They fix the gap

    Create a missing pod, replace a failed container

  4. 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

  1. 1.How does Kubernetes work, in the documentation's terms?
  2. 2.What happens when a node stops sending its heartbeat messages?
  3. 3.Where did Kubernetes get its main ideas?

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.

Sources (4)

No source, no claim. Every fact in this lesson (17 claims) cites at least one of these.

  1. [1]Kubernetes · Wikipedia
  2. [2]Large-scale cluster management at Google with Borg · Google Research (EuroSys 2015)
  3. [3]Overview | Kubernetes · Kubernetes documentation
  4. [4]Controllers | Kubernetes · Kubernetes documentation
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗