Writing labs
A lab is a folder in the repository: a lab.yaml that describes it, the manifests that set up and break a cluster, and a script that fixes it. You do not need to know Go. This guide covers everything from the first idea to a merged pull request, and the complete lab.yaml reference.
The workflow
make new-lab ID=pvc-pending-no-storageclass TRACK=0-foundations # copy the template
$EDITOR labs/pvc-pending-no-storageclass/lab.yaml # write it
make validate # schema and rules, in under a second
make lab-test LAB=pvc-pending-no-storageclass # a real cluster: starts broken, your fix scores 100
Then open a pull request. CI runs the same validation and lab test, and a maintainer reviews the content. Contributing covers setting up the tools; the quickest route is GitHub Codespaces, where everything is installed for you.
A lab directory looks like this:
labs/pvc-pending-no-storageclass/
lab.yaml title, goal, cluster, checks, hints, further reading
setup/*.yaml the healthy starting state, applied first
faults/*.yaml the failure, applied after setup
solution/*.sh the fix a learner would make; lab CI runs it
logs/*.log optional: what `kubectl logs` returns
The directory name must equal the lab’s id.
Designing a good lab
- Start from a real failure. The best labs come from something you have debugged at work or seen in an incident report: a GPU pod stuck Pending, a quota that deadlocks a rollout, a webhook that blocks every deploy. Write down what you saw first, what you checked, and what the fix was.
- One clear goal. The
goalsays what is broken, what “fixed” means, and the rules: what the learner must not change. “Get the Deployment Running” is not enough if deleting the ResourceQuota would do it; say “without changing the quota”. - Enforce the rules with hidden checks. For every rule in the goal, add a hidden check. Learners see that hidden checks exist, and see their results after grading.
- Grade outcomes, not keystrokes. Check the state of the cluster, not the commands used to get there, and accept every reasonable fix. If both
kubectl set envand editing the YAML work, both must pass. - Write the solution a learner would write. Lab CI runs your solution. If the shortest passing command is not what a learner would do, write the learner’s path. Real paths find real problems: the first version of
gpu-pod-pendingpassed CI with a one-line fix, while the fix a learner would try deadlocked behind the namespace’s GPU quota. That deadlock is now part of the lab. - Hints climb. The first hint says where to look, the second what to look for, the last what to change, without the exact command.
- Connect it to production. Three
inProductionlines say what to check or what differs on a real cluster, andresourceslink to official documentation.
lab.yaml reference
| Field | Required | Description |
|---|---|---|
id |
yes | 3–50 characters of a-z, 0-9 and -. Equals the directory name. Never change it after merging: progress is stored by id. |
title |
yes | Short and specific. Shown on cards, the lab page and the workspace. |
summary |
yes | One sentence, at most 160 characters. Shown on cards and in search results. |
track |
yes | One of the track ids below. |
format |
yes | scenario, timed-scenario, flow, capstone or playground. |
difficulty |
yes, except playgrounds | beginner (100 points), intermediate (200) or advanced (300). |
estimatedMinutes |
yes | Typical time to finish, 5–60. |
timeLimitMinutes |
yes | Hard limit for the session, from estimatedMinutes up to 60. Learners get 10 more minutes of grace. |
authors |
recommended | GitHub usernames. Credited on the lab page. |
goal |
yes | What is broken, what fixed means, and the rules. |
inProduction |
yes, except playgrounds | Exactly three lines. |
hints |
recommended | Revealed one at a time. In a playground, shown as “Ideas to try”. |
resources |
recommended | Further reading: {title, url} with https URLs, ideally official documentation. |
setup |
yes, except playgrounds | Manifest files, applied in order. |
faults |
scenarios | Manifest files applied after setup. Scenarios need at least one. |
solution |
yes, except playgrounds | Shell scripts run with KUBECONFIG set. |
cluster |
yes | The session cluster’s nodes and served logs. See below. |
checks |
yes, except playgrounds | How the lab is graded. See below. |
Tracks
| id | Track |
|---|---|
0-foundations |
Foundations |
1-kubernetes-internals |
Kubernetes internals |
2-gpu-scheduling |
GPU infrastructure & scheduling |
3-serving-inference |
Serving & inference |
4-observability |
Observability |
5-platform |
Platform & cost |
6-security |
Security |
7-distributed |
Distributed workloads |
Formats
- scenario: starts broken; the learner diagnoses and fixes it. Lab CI fails if a scenario starts with a full score.
- timed-scenario: a longer scenario, typically 30–60 minutes.
- flow: guided practice of one skill; it may start in a passing state.
- capstone: ties a track together.
- playground: a cluster with no checks, score or solution. Listed on the Playground page.
The cluster
cluster:
nodes:
- {namePrefix: gpu-node, count: 3, cpu: "24", memory: 96Gi, gpus: 2, gpuProduct: NVIDIA-L4}
- namePrefix: storage
count: 2
cpu: "16"
memory: 64Gi
labels: {disktype: nvme}
taints: [{key: dedicated, value: storage, effect: NoSchedule}]
logs:
- {namespace: shop, containers: [api], file: logs/orders-api.log}
Nodes. Each group creates count nodes named <namePrefix>-a, -b, … (or -001, -002, … above 26; a single node is just <namePrefix>). cpu and memory set capacity and allocatable. Every node gets the standard kubernetes.io/hostname, kubernetes.io/os and kubernetes.io/arch labels. Add your own with labels and taints. Use realistic shapes: if you label a node with a cloud instance type, its CPU, memory and GPU count should match that type.
GPU nodes. Set gpus and, optionally, gpuProduct. The node then advertises nvidia.com/gpu in capacity and allocatable and carries the labels NVIDIA GPU Feature Discovery sets: nvidia.com/gpu.present=true, nvidia.com/gpu.count and nvidia.com/gpu.product. Use the product strings Feature Discovery reports, such as NVIDIA-L4, NVIDIA-A100-SXM4-80GB or NVIDIA-H100-80GB-HBM3.
How pods behave. Lab clusters use the real Kubernetes control plane with KWOK-managed nodes (see How it works). Scheduling, quotas, admission, controllers and events are real. Pods that are scheduled become Running and Ready, and Job pods complete. No container processes run, so exec, port-forward and logs --previous are unavailable, and nothing listens on a port. Design labs around what the API shows.
Logs. Each logs entry serves a plain-text file as the output of kubectl logs for the named containers in a namespace. Write the lines a real process would print, so the learner can diagnose from them.
Start-up failures. To make a container fail until it is configured correctly, annotate the pod template:
template:
metadata:
annotations:
labcluster.dev/requires-env: DATABASE_URL
While the first container has no DATABASE_URL environment variable (from a value, a Secret or a ConfigMap), its pods exit with status 1 and loop in CrashLoopBackOff. Once the variable is present, they start. Add a hidden check that the annotation is unchanged, so removing it does not count as a fix.
Checks
checks:
- id: pod-running
title: The vllm-qwen pod is Running
points: 30
kube:
apiVersion: v1
kind: Pod
namespace: inference
labelSelector: app=vllm-qwen
match: any
jsonPath: '{.status.phase}'
op: equals
value: Running
- id: capacity-unchanged
title: GPU node allocatable unchanged (2 per node)
points: 10
hidden: true
kube:
apiVersion: v1
kind: Node
labelSelector: nvidia.com/gpu.present=true
minCount: 3
jsonPath: '{.status.allocatable.nvidia\.com/gpu}'
op: equals
value: "2"
- id: pool-unchanged
title: GPU node pool unchanged (3 nodes, no new taints)
points: 10
hidden: true
command:
run: |
test "$(kubectl get nodes -l nvidia.com/gpu.present=true -o name | wc -l)" -eq 3 &&
test -z "$(kubectl get nodes -l nvidia.com/gpu.present=true -o jsonpath='{.items[*].spec.taints}')"
exitCode: 0
Every check has a unique id, a title written as the passing state (“The pod is Running”, not “Check the pod”), and points greater than zero. At least one check must be visible. Points can add up to any total; 100 is easiest for learners to read.
kube checks
| Field | Description |
|---|---|
apiVersion, kind |
The object type, e.g. apps/v1 and Deployment. |
namespace |
For namespaced kinds. |
name or labelSelector |
Exactly one. (A Node check may omit both to match every node.) |
match |
With several objects: all (default) or any must pass. |
minCount |
With a selector: at least this many objects must exist (default 1). |
includeTerminating |
Count objects that are being deleted. By default they are ignored. |
jsonPath |
A kubectl JSONPath expression, e.g. {.spec.replicas}. Escape dots in keys: nvidia\.com/gpu. |
op |
equals, notEquals, contains, exists, notExists, lte or gte. |
value |
For every op except exists and notExists. |
equals, notEquals and contains compare exactly what kubectl get -o jsonpath=... prints. lte and gte compare Kubernetes quantities, so 500m, 2 and 16Gi work.
command checks
| Field | Description |
|---|---|
run |
A shell script, run with sh -c and KUBECONFIG pointing at the session cluster. kubectl is on the PATH. |
exitCode |
The exit code that passes, usually 0. |
stdoutContains |
Optional text the output must contain. |
Use command checks for conditions a single JSONPath cannot express, such as counting objects or comparing two fields. Keep them fast (each check has 20 seconds), read-only and free of network access other than the session’s API server.
Hidden checks
Set hidden: true. Learners see how many hidden checks a lab has, and each one’s title and result after grading. Use them for the rules in the goal (capacity unchanged, quota still in place, replica count unchanged, the GPU request not removed) so a shortcut that breaks a rule does not earn full marks.
Testing a lab
make validate checks every lab against the schema and rules in this guide and reports every problem at once.
make lab-test LAB=<id> is the same test CI runs:
- create a session cluster with your nodes and logs;
- apply
setup/, thenfaults/; - grade, and require a scenario to start below a full score;
- run your
solution/scripts; - require a full score within 60 seconds.
To explore the broken cluster yourself, keep it after the test and point kubectl at it:
bin/labcluster lab test --bin-dir bin --lab <id> --keep labs
export KUBECONFIG=<the path it prints>
kubectl get pods -A
To play the lab exactly as a learner does, with the workspace, hints and grading, run the whole platform locally with make dev (see Contributing).
Review checklist
Maintainers check each new lab for:
- [ ] A realistic failure, a clear goal and explicit rules.
- [ ] Every rule enforced by a hidden check; every reasonable fix passes.
- [ ] A reference solution a learner would write, passing in CI.
- [ ] Hints that climb without giving the answer away in the first one.
- [ ] Three accurate
inProductionlines andresourcesthat link to official documentation. - [ ] Facts that match the upstream documentation for the versions involved: flags, field names, label values, error messages.
- [ ] Realistic node shapes and product names.
Licence and credit
Lab content is licensed under CC BY 4.0, so others can reuse it with credit. The usernames in authors are shown on the lab page and link to your GitHub profile.