Skip to content

Phase 0: Mental Model

Time: 1 evening. Goal: understand WHY k8s exists before touching it.

Why Kubernetes at all

What problem does k8s solve that docker run and docker compose don't?

  • Scheduling across multiple machines. Compose runs on one host. k8s treats a fleet of machines as one big pool of CPU and memory.
  • Self-healing. A container dies, a node dies, k8s reschedules the workload somewhere else without you waking up.
  • Rolling updates. Replace v1 with v2 gradually, with health checks gating each step, and roll back with one command.
  • Service discovery at scale. Built-in DNS and virtual IPs so services find each other no matter which node they land on.

The core idea: declarative desired state

With Docker you say "run this container" (imperative). With k8s you say "I want 3 replicas of this image to always exist" (declarative), and a control loop continuously makes reality match your declaration.

This is the single most important idea in Kubernetes. Everything else - controllers, reconciliation, kubectl apply - follows from it.

Architecture at a glance

You don't need to memorize this yet. Just know the API server is the front door and everything talks to it.

  • Control plane: API server, scheduler, controller manager, etcd (the database holding desired state).
  • Worker nodes: kubelet (the agent that runs pods), container runtime (containerd these days, not Docker itself).

The Docker-to-k8s map

Keep this table in your head. The full version lives in the cheat sheet.

Docker conceptKubernetes equivalent
docker runPod (lowest unit, wraps 1+ containers)
docker compose serviceDeployment
docker compose fileA set of YAML manifests
compose networks / service namesService (ClusterIP) + cluster DNS
-p 8080:80Service (NodePort/LoadBalancer) or Ingress
volumesPersistentVolume + PersistentVolumeClaim
.env / environment:ConfigMap + Secret
restart: alwaysBuilt-in, controllers reschedule pods
docker logs / execkubectl logs / kubectl exec

Checkpoint

Before moving on, you should be able to explain to a colleague, in your own words:

  1. What "declarative desired state" means and how it differs from docker run.
  2. Why compose is not enough once you have more than one machine.
  3. What the API server is.

Next: Phase 1: Local Cluster + kubectl

A VineLab lab. Released under the MIT License.