DEV Community

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.

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 kubectl context 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) and kubectl patch options - 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:

  1. 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.
  2. CrashLoopBackOff (wcpgw-crashloop) - A worker exits immediately (exit 1) on startup. Inspect previous container logs (--previous) and fix its startup command.
  3. OOMKilled (Exit Code 137) (wcpgw-oomkilled) - A batch processor allocates ~60 MiB inside a 32Mi memory limit. Confirm OOMKilled / exit code 137 and adjust resources.limits.memory.
  4. Pending Pods & Scheduling (wcpgw-pending) - Pods never schedule due to an unsatisfiable nodeSelector. Inspect Pod YAML and FailedScheduling events to unblock placement.
  5. 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.
  6. Failed Liveness & Readiness Probes (wcpgw-probes) - Pods stay Running (0/1 ready) because readinessProbe checks /readyz (404) instead of /healthz (200), leaving Service endpoints empty.
  7. DNS & Service Discovery (wcpgw-dns) - caller-client fails to reach inventory-api because the Service selector (app: inventory-api-v99) mismatches the Pod labels.
  8. Ingress & TLS Errors (wcpgw-ingress) - Requests to https://portal.wcpgw.local return 502 Bad Gateway because the Ingress routes to backend port 8080 instead of the Service port 80.
  9. SecurityContext & RBAC Permissions (wcpgw-perms) - readOnlyRootFilesystem: true blocks writes to /var/log/audit-agent. Verify ServiceAccount permissions via kubectl auth can-i and mount an emptyDir volume.
  10. Storage & Mount Issues (wcpgw-storage) - A Pod stays Pending waiting on an unbound PersistentVolumeClaim whose storageClassName doesn'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:

  1. Scope your context to the target namespace
kubectl config set-context --current --namespace=<namespace>
  1. Check Pod phase, READY count, and restart counters
kubectl get pods -o wide
  1. Inspect the full live manifest and recent cluster events
kubectl get pod <pod-name> -o yaml | less
kubectl describe pod <pod-name>
  1. 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:

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!

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.