What Kubernetes is
Build a cluster and watch it keep an app running.
cd ~/lab && curl -fsSLO https://secopslog.com/lab-files/k8s-fund/whatis.tar.gz && tar -xzf whatis.tar.gz, which creates ~/lab/whatis/. SHA-256: 20230590edbf22f0001ca4644c8281c891b27d82e6ac293fa230751926af7523With Docker you can start a container on one machine. If that machine reboots, the container is gone until someone starts it again. If you need three copies, you start three and keep track of them yourself. And when a new version comes out, you stop the old containers and start new ones, hoping nobody notices the gap. That works for a laptop. It stops working once an app has to keep running while machines fail and people go home.
Kubernetes takes that bookkeeping off you. You tell it what you want, for example "three copies of this web server", and it keeps checking whether that is true. When a copy disappears, it starts another. When a machine dies, it starts the copies somewhere else. You stop giving orders and start describing a result. Everything else in this course builds on that one idea.
What you need
A Linux machine or virtual machine with Docker Engine and about 4 GB of free memory. The Ubuntu VM from the Docker course works well. Every lesson in this course ran on Ubuntu 26.04 with Docker Engine 29.9.3, and the install script below is for Linux. Docker Desktop on macOS or Windows can run kind too, but you would install the tools with your package manager, and a few later steps that reach a node's IP address directly only work from inside Linux.
You also need two tools. kind ("Kubernetes in Docker") builds a cluster out of Docker containers, so you can run a real multi-node cluster on one machine. kubectl is the command-line client you use to talk to any Kubernetes cluster, including big ones in the cloud. This script installs both and refuses to continue if a download does not match the checksum its project publishes:
#!/usr/bin/env bash# Installs kind and kubectl into /usr/local/bin, each checked against the sha256 its project publishes.# Run it on the Linux machine or VM where Docker runs: ./install-tools.shset -euo pipefailKIND=v0.33.0KUBECTL=$(curl --retry 3 --retry-all-errors -fsSL https://dl.k8s.io/release/stable.txt) # the newest stable Kubernetes releasecase $(uname -m) inx86_64) arch=amd64 ;;aarch64|arm64) arch=arm64 ;;*) echo "unsupported CPU: $(uname -m)"; exit 1 ;;esactmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXITcd "$tmp"curl --retry 3 --retry-all-errors -fsSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$KIND/kind-linux-$arch"curl --retry 3 --retry-all-errors -fsSLo kind.sha256 "https://github.com/kubernetes-sigs/kind/releases/download/$KIND/kind-linux-$arch.sha256sum"echo "$(cut -d' ' -f1 kind.sha256) kind" | sha256sum --checkcurl --retry 3 --retry-all-errors -fsSLo kubectl "https://dl.k8s.io/release/$KUBECTL/bin/linux/$arch/kubectl"curl --retry 3 --retry-all-errors -fsSLo kubectl.sha256 "https://dl.k8s.io/release/$KUBECTL/bin/linux/$arch/kubectl.sha256"echo "$(cat kubectl.sha256) kubectl" | sha256sum --checksudo install -m 0755 kind kubectl /usr/local/bin/kind versionkubectl version --client
The two OK lines are the checksum checks passing. kubectl is v1.37.2, the newest stable Kubernetes release when these labs ran.
Build a cluster
A cluster is a group of machines, called nodes, that Kubernetes treats as one place to run things. This file asks kind for three nodes: one control-plane node that makes decisions and two workers that run your apps.
# One control-plane node and two workers, each a Docker container on this machine.kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4nodes:- role: control-plane- role: worker- role: worker
kind printed a few steps, then pointed kubectl at the new cluster (the context kind-lab). Asked straight away, all three nodes were NotReady: they existed, but their networking was still starting. Half a minute later all three were Ready. The VERSION column shows Kubernetes v1.37.0, the version kind v0.33.0 builds by default. kubectl can be a little newer than the cluster, so v1.37.2 talks to it without trouble.
Each node is just a container:
On a real cluster each node would be its own server or cloud VM. Here they share one machine, which is fine for learning, since Kubernetes behaves the same way.
Describe what you want
Now ask for three copies of nginx. A Deployment is the object that says "keep this many copies of this container running". Each running copy lives in a Pod, the smallest thing Kubernetes runs. Both get their own lessons soon.
Kubernetes chose the nodes itself. Two Pods landed on one worker and one on the other, and the control-plane node got none, because kind keeps apps off it. Each Pod got its own IP address. You did not pick any of that.
Break it and watch
Delete one Pod, the kind of thing a crash or a failed machine does to you:
The deleted Pod's name is gone from the list. A new Pod, a few seconds younger than the other two, has taken its place. Nobody told Kubernetes to start it. The Deployment still says three, the cluster saw two, and it closed the gap. That loop of compare, then fix, runs all the time, and it is called reconciliation.
This is also why you rarely touch Pods directly. Delete a Pod that a Deployment owns and you get a new one. To really remove the app, you delete the Deployment.
Hands-on
1. Delete all three Pods at once: kubectl delete pods -l app=web. The -l picks Pods by their label; lesson 7, Labels, explains how.
2. Wait for the Deployment to catch up with kubectl rollout status deployment/web, then list the Pods with kubectl get pods. How many are there, and how old?
3. Remove the app properly: kubectl delete deployment web.
4. Wait for its Pods to go with kubectl wait --for=delete pod -l app=web --timeout=90s, then run kubectl get pods again.
5. Check which kind clusters exist: kind get clusters.
What you should see: in step 2 the rollout status counts back up from 0 of 3, and the list shows three Pods with new names, all a second or two old. In step 4 each Pod reports condition met as it goes, and kubectl get pods says No resources found in default namespace. Step 5 prints lab.
Every later lesson uses this lab cluster, so keep it running. If you need the memory back, kind delete cluster --name lab removes it, and kind create cluster --name lab --config kind.yaml builds a fresh one in about a minute.
Remember
You describe the state you want and Kubernetes keeps making it true. A Deployment holds the "how many", Pods are the running copies, and deleting a Pod only gets you a replacement.
docker ps listed one container per node. On a real cluster each node would be a server or VM.docker ps.