Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Introduction  ›  Lesson

Overview of Kubernetes

Overview of Kubernetes 12 minKubernetes is a container orchestrator that stores the state you declare and runs control loops that keep the real cluster matching it.

Overview of Kubernetes

Imagine a small notes app: a web front end, a database and a nightly backup. On one laptop you start them by hand. On twenty servers, with traffic spikes and machines that fail at 3 a.m., starting things by hand stops working. Kubernetes is the system that takes over that job.

The rule

You declare what should run; Kubernetes keeps making it true.

Kubernetes (often written K8s — a K, eight letters, an s) is an open-source container orchestrator. You hand it a description of the world you want, and it works continuously to make the real world match.

Here is a small description for our notes app:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: notes-web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: notes-web
  template:
    metadata:
      labels:
        app: notes-web
    spec:
      containers:
        - name: web
          image: ghcr.io/example/notes-web:1.2
          ports:
            - containerPort: 8080

Read it as a wish: "three copies of the notes-web container should be running." It says nothing about which machines, or what to do if one crashes. Those decisions belong to Kubernetes.

Three ideas carry the whole system:

  • Desired state — what you asked for, stored in the cluster.
  • Actual state — what is really running right now.
  • Control loops — small programs that compare the two, over and over, and act to close any gap.

The project grew out of Google's experience running containers at enormous scale, was released as open source in 2014, and is now looked after by the Cloud Native Computing Foundation. Every major cloud offers it.

The shortcut

When you meet any Kubernetes behaviour, ask: what was the desired state, what is the actual state, and which loop closes the gap? Almost every "why did it do that?" question answers itself.

A server dies at 3 a.m.Step 1 of 4
  1. Desired state

    The cluster has stored your wish: three copies of notes-web.

The trap is thinking of Kubernetes as a script that runs once. It is not a "do this" tool; it is a "keep this true" tool. If you delete a copy by hand, it comes back, because the wish still says three.

Drills

Answer fast — trust the rule.

quick drill

What does the "8" in K8s stand for?

quick drill

In the notes-web manifest, what does replicas: 3 describe?

quick drill

You delete one of the three notes-web copies by hand. What happens next?

quick drill

Which phrase best describes Kubernetes?

Remember

  • You declare what should run; Kubernetes keeps making it true.
  • Ask: desired state, actual state, which loop closes the gap?
  • Trap: treating it as a one-off script. It keeps enforcing your wish.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainDesired versus actual state

The notes-web Deployment asks for 3 replicas. Someone deletes one pod by hand. Explain, using the words desired state, actual state and control loop, what Kubernetes does next and why.