What Could Possibly Have Gone Wrong? 10 Hands-On Kubernetes Debugging Labs
When a Kubernetes deployment breaks in staging or production, theory quickly gives way to muscle memory: Which kubectl command tells me why this Pod isn't starting? Is it an image tag, a missing ConfigMap, a failing readinessProbe, or an unbound PersistentVolumeClaim?
To help application developers, testers, and operators (especially those who are new to kubernetes) practice those diagnostic workflows safely, I created "What Could Possibly Have Gone Wrong?" - a series of 10 interactive, browser-based Kubernetes troubleshooting scenarios on KillerCoda, backed by an open-source repository.
- Interactive KillerCoda Labs: https://killercoda.com/what-could-possibly-have-gone-wrong
- GitHub Repository: https://github.com/katalyticIT/killercoda-k8s-wcphgw
How Each Scenario Works
Every lab spins up a real Kubernetes cluster in your browser, deploys a broken workload into its own dedicated namespace, and guides you through a two-step structure:
- Step 1 - Investigate & Try Yourself: Sets your
kubectlcontext to the scenario namespace and gives you the core inspection commands (kubectl get pods,kubectl get pod <name> -o yaml | less,kubectl describe,kubectl logs --previous,kubectl auth can-i, etc.) so you can diagnose and fix the issue independently without a blocking check. - Step 2 - Guided Solution: Already fixed it in Step 1? Hit Check right away to verify your solution. Stuck or want to compare approaches? Click through the executable command blocks - complete with both
kubectl edit(vi) andkubectl patchoptions - and validate your fix with an automated verification script.
The 10 Scenarios at a Glance
Each lab focuses on a distinct failure pattern you routinely encounter across development, testing, and operations:
- ErrImagePull / ImagePullBackOff (
wcpgw-imgpull) - A Deployment references a non-existent image tag (nginx:1.999-nonexistent). Inspect Pod events and roll out a valid tag. - CrashLoopBackOff (
wcpgw-crashloop) - A worker exits immediately (exit 1) on startup. Inspect previous container logs (--previous) and fix its startup command. - OOMKilled (Exit Code 137) (
wcpgw-oomkilled) - A batch processor allocates ~60 MiB inside a 32Mi memory limit. Confirm OOMKilled / exit code 137 and adjustresources.limits.memory. - Pending Pods & Scheduling (
wcpgw-pending) - Pods never schedule due to an unsatisfiablenodeSelector. Inspect Pod YAML and FailedScheduling events to unblock placement. - CreateContainerConfigError (
wcpgw-configerr) - billing-worker expects a missing billing-config ConfigMap while us-billing-config already exists. Choose between creating the missing config or switching references. - Failed Liveness & Readiness Probes (
wcpgw-probes) - Pods stay Running (0/1 ready) becausereadinessProbechecks/readyz(404) instead of/healthz(200), leaving Service endpoints empty. - DNS & Service Discovery (
wcpgw-dns) - caller-client fails to reach inventory-api because the Service selector (app: inventory-api-v99) mismatches the Pod labels. - Ingress & TLS Errors (
wcpgw-ingress) - Requests tohttps://portal.wcpgw.localreturn 502 Bad Gateway because the Ingress routes to backend port 8080 instead of the Service port 80. - SecurityContext & RBAC Permissions (
wcpgw-perms) -readOnlyRootFilesystem: trueblocks writes to/var/log/audit-agent. Verify ServiceAccount permissions viakubectl auth can-iand mount anemptyDirvolume. - Storage & Mount Issues (
wcpgw-storage) - A Pod stays Pending waiting on an unbound PersistentVolumeClaim whosestorageClassNamedoesn't match the available PersistentVolume.
A Quick Diagnostic Habit That Solves 80% of Issues
Across all 10 labs, the same four-step triage loop applies:
- Scope your context to the target namespace
kubectl config set-context --current --namespace=<namespace>
- Check Pod phase, READY count, and restart counters
kubectl get pods -o wide
- Inspect the full live manifest and recent cluster events
kubectl get pod <pod-name> -o yaml | less
kubectl describe pod <pod-name>
- Check current and crashed container logs
kubectl logs <pod-name> --previous --tail=30
Once you know where in the lifecycle a Pod is stuck - scheduling (Pending), config/image setup (ErrImagePull, CreateContainerConfigError), runtime (CrashLoopBackOff, OOMKilled, SecurityContext), or networking/storage (ReadinessProbe, empty Endpoints, Ingress, PVC) - the fix is usually straightforward.
Open Source & Dual Licensing
All scenario definitions, setup scripts, verification scripts, and cheat sheets are available on GitHub:
- Repository: https://github.com/katalyticIT/killercoda-k8s-wcpgw
- Code & Scripts (
*.sh,*.json, YAML): Licensed under the Apache License 2.0 - Text & Documentation (
*.md): Licensed under CC BY 4.0
Feel free to try the labs, open an issue or PR if you hit any rough edges, or suggest additional real-world failure scenarios you'd like to see added!
Comments
No comments yet. Start the discussion.