Skip to content
System design on Kubernetes · Chapter 1 of 20 Preface

Preface

“Then it runs on Kubernetes” is, in many designs, the sentence after which nobody asks any more. As if the cluster answered the questions that were on the whiteboard before. It does not. A Deployment with three replicas does not survive a zone outage by itself. An autoscaler does not help when the node is the bottleneck. A retry in the mesh can hide a fault or double it. And every proxy you put in between costs CPU. How much, the documentation does not tell you. Only a measurement does.

This course takes a system that already runs and moves it to Kubernetes. The URL shortener kurz and its click counter zaehler come from the predecessor course, where they grew by hand on three VMs. Here they get a k3s cluster with three zones on the same three VMs. Every building block gets its Kubernetes form: Deployment and probes, Gateway API, operators for Valkey, PostgreSQL and NATS, HPA and KEDA, rate limits in the Gateway, a service mesh, topology spread and PDBs. Every decision is measured with k6, every building block deliberately broken once. Every day ends with numbers: requests per second, p95, error rate. Where the predecessor course has a number, the comparison stands next to it.

The book is for platform and DevOps engineers, for developers who operate their own services, and for anyone preparing for a system design interview who wants to say more than “then Kubernetes scales it”. You should know kubectl, know what a Pod, a Deployment and a Service are, and be confident with Linux in the terminal. You do not need a cloud: everything runs on three self-managed VMs, and every building block is open source.

The predecessor course

“System design hands-on” built kurz from a single instance into a distributed system: HAProxy in front, Valkey as a cache, PostgreSQL with a replica and PgBouncer, NATS JetStream for clicks, rate limits, timeouts, circuit breakers, failover with keepalived. All with systemd and configuration files, all measured.

This course builds on it, but does not require it:

  • With the predecessor course: Day 0 backs up the database with its roughly 2.7 million links, clears the VMs and builds the cluster from them. You already have the Go code of kurz and zaehler.
  • Without the predecessor course: You start with three fresh VMs, skip the clean-up on Day 0 and get the code from the companion repo github.com/itdrills/system-design-zum-anfassen. Then you lack the dump that Day 1 restores: the table links is empty. Before Day 2, create a few thousand links via POST /api/links so that the load scripts find codes. Your numbers will then differ somewhat, because the table and indexes are smaller.
  • What is new: not the patterns, but their form. A health check is now called a readiness probe, a failover is the operator’s job, a rate limit is a policy at the Gateway. Also new are the questions that did not exist on the VMs: requests and limits, throttling, autoscaling, zones, mesh.

How the book works

  • One day, one topic. Each day has a goal, a time estimate, a short briefing and 5–8 drills. You type every command yourself and compare with “Expected”.
  • Measure instead of claim. k6 runs on s1 and generates load through the Gateway, before and after. A decision counts only when the number backs it up. Where a measurement showed something other than expected, the book says so.
  • Breaking things is part of it. Pods die, nodes lose the network, the primary changes under load, an entire zone fails. Only then does it show whether a design holds.
  • No helper scripts. Every step is shown as a single command, manifests and code as heredocs, including the checkpoint at the end of each day. Every command has a comment line that says what it does.
  • Where the command runs is stated in the first line of each code block: # on s1, # on s2 or # on s3. Almost everything runs on s1. You log in to s2 and s3 only when a node itself has to do something, such as kill a process or cut its network.
  • KUBECONFIG points to /etc/rancher/k3s/k3s.yaml. Day 0 adds the variable to ~/.bashrc. Where a command runs in a new shell without a login, the block sets it again.
  • Files live under ~/sdk/tagNN on s1, one directory per day. Later days copy what they need from earlier ones and re-apply manifests from earlier directories.
  • Speed drills, Checkpoint, Challenge, Interview note, Enterprise note close every day. The challenge is a task without instructions, with a hint and a solution. The interview note says how to explain the topic of the day in a job interview; the enterprise note says what is different in large environments.
  • “Happened during testing” is the name of the boxes that say what went wrong while writing. They are real and often more instructive than the drill before them.

At the end:

  • Competition (Day 15): an evening with load and six faults in the running cluster, against the clock and with the measurement as proof.
  • Appendix A is the cheat sheet: the course’s commands by topic, the measurement patterns and the traps. Appendix B is the final exam with ten tasks. Appendix C works through five interview problems, answered with the measurements from this course.

The days at a glance

Day Topic Duration
0 The ground: from the legacy system to k3s approx. 75 min
1 kurz as a Deployment: CloudNativePG, probes, ConfigMap, Secret approx. 75 min
2 Measuring in the cluster: requests, limits, throttling approx. 90 min
3 Gateway API with Envoy Gateway approx. 90 min
4 Failures: Pods, rollouts, a node disappears approx. 90 min
5 Cache with Valkey via an operator approx. 90 min
6 PostgreSQL with replicas approx. 90 min
7 Failover and pooler approx. 100 min
8 Asynchronous with NATS JetStream approx. 100 min
9 Scaling with the HPA approx. 100 min
10 Scaling by queue length with KEDA approx. 110 min
11 Rate limiting and backpressure in the Gateway approx. 100 min
12 Linkerd: retries, timeouts, mTLS approx. 110 min
13 Zones: topology spread, PDBs, losing a zone approx. 120 min
14 Capacity and the design document approx. 120 min
15 Competition: the overloaded cluster approx. 90 min

Time: Days 0 to 14 add up to a good 24 hours (1460 minutes); the competition and the final exam add one and a half and two hours, just under 28 hours in total. With one training day per evening and five evenings per week, you are through in four weeks. The later days are longer, because measurements with autoscaling and failures take minutes until things settle.

The training ground

VM Role IP in the book Zone In the lab
s1 k3s server, registry, k6, workstation 172.16.0.126 zone-a 4 vCPU, 11 GB
s2 k3s agent 172.16.0.228 zone-b 2 vCPU, 4 GB
s3 k3s agent 172.16.0.83 zone-c 2 vCPU, 4 GB
  • All VMs run Ubuntu 24.04 with SSH access and sudo, in a shared network in which they can reach each other without restrictions.
  • Each VM is its own zone (label topology.kubernetes.io/zone). In the lab, a zone outage is a VM whose network is cut with iptables, with a timer that lifts the block again.
  • Internet access from the VMs for packages, Helm charts, container images and downloads from the official release pages. Your own images live in a registry on s1.
  • Disk space: in the lab, s2 and s3 have 29 GB each; at the end of the course about 9 GB of it is used. The volumes live as directories on the node via local-path.
  • The measured values depend on this hardware. More cores shift the limits; the direction of the results stays the same. s1 carries k6, the k3s server and some of the Pods. Measurements there are meaningful up to about 3000 requests per second (Day 2); above that, you are measuring k6.
  • A snapshot of all VMs after Day 0 and after Day 8 saves you an evening if things go wrong.

Proxmox, VMware, a cloud or Multipass, it does not matter. On a Mac with Apple Silicon, Multipass VMs are arm64. All downloads detect the architecture themselves (ARCH=$(dpkg --print-architecture)). The outputs in the book come from amd64.

Versions

Component Version
k3s (Kubernetes) v1.37.2+k3s1
Helm v4.3.2
Gateway API (CRDs from k3s) v1.6.3, channel standard
Envoy Gateway v1.10.0
CloudNativePG / kubectl-cnpg 1.30.2 (chart 0.29.2)
PostgreSQL / PgBouncer 18.7 / 1.26.1
Valkey / Valkey Operator 9.2.0 / 0.9.0
NATS / NACK 2.15.3 / 0.25.0 (chart 0.36.0)
KEDA 2.21.1
Linkerd edge-26.11.2
k6 2.4.0
Go 1.27.4

The Valkey Operator is still an early project (API v1alpha1) and calls itself “not ready for production”. Day 5 uses it anyway, because it shows how an operator builds a cluster with shards. For production, the enterprise note says what else is available.

What you can do afterwards

  • Bring a service into the cluster so that probes, rollouts and resources match its behavior under load, and know the traps of kubectl apply alongside set, patch and autoscalers.
  • Justify requests and limits with measurements instead of copying them from templates: make throttling, OOMKilled and QoS classes visible.
  • Build the entry point with the Gateway API: load balancing, canary, retries, passive health checks, local and global rate limits, circuit breakers.
  • Run state with operators: Valkey cluster with shards, PostgreSQL with replicas, switchover, failover and pooler, NATS JetStream with declarative streams.
  • Scale on the right signal: CPU with the HPA, backlog with KEDA, down to zero and back.
  • Use a service mesh and know its price: mTLS, retries, timeouts, failure accrual.
  • Spread across zones, drain nodes under load, let a zone fail and measure the damage.
  • Determine capacity with a zone reserve and write a design document in which every number has a day.
  • In the interview, say what a building block really costs in the cluster, because you measured it.

What was tested

All commands and outputs come from real runs on the described training ground in November 2026, shortened where it makes sense. Measured values vary from run to run. Pod names, IP addresses, codes, times and numbers will differ for you; the order of magnitude should match.

Hint: This course is an independent practice course. Kubernetes, k3s, Envoy, Linkerd, KEDA and NATS are projects of the Cloud Native Computing Foundation (CNCF), Valkey is a project of the Linux Foundation, CloudNativePG a project of the CloudNativePG community. PostgreSQL is a trademark of the PostgreSQL Community Association, k6 a project of Grafana Labs, Go a project of Google. The book is not affiliated with these organizations and projects and is neither reviewed nor endorsed by them.

The passwords in the book (lab-kurz-123 and relatives) are for the lab only. In production, credentials belong in a secret manager, never in a book, a manifest in Git or a shell history.

Enjoy the drill book.

Contents

More