Skip to content

Tool · Open source

KubeDrill: practice kubectl. No cluster required.

KubeDrill simulates a Kubernetes cluster on your machine. You work with the real kubectl, learn commands and resources and hunt down injected faults in challenges – without setting up a cluster.

$ kubedrill start
$ kubectl --context kubedrill create deployment nginx --image=nginx:1.27
$ kubectl --context kubedrill get deployments,pods
NAME                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx   1/1     1            1           4s

NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-574fbc9564-ssvv7   1/1     Running   0          4s
$ kubedrill challenge start image-pull-backoff
$ kubectl --context kubedrill get pods
NAME                     READY   STATUS             RESTARTS   AGE
nginx-574fbc9564-ssvv7   1/1     Running            0          8s
nginx-7ff4b6c78d-vqsmz   0/1     ImagePullBackOff   0          5s

Using it in six steps

All output on this page comes from a real run of KubeDrill v0.1.0 on Ubuntu 24.04. Pod names and times will differ on your machine.

1 · Install and check

Install KubeDrill with brew, apt or dnf (see Install). You also need kubectl. Afterwards kubedrill doctor checks the setup; before the first start the server and context are still missing, which is expected:

$ kubedrill doctor
[ok  ] kubectl found in PATH /usr/local/bin/kubectl
       Client Version: v1.37.2
[FAIL] KubeDrill server running
       -> run `kubedrill start`
[FAIL] context "kubedrill" present in /home/ubuntu/.kube/config
       -> run `kubedrill kubeconfig merge` or use `kubedrill kubectl`
current-context: kind-werkzeuge

2 · Start the simulator

kubedrill start runs the simulated cluster in the background and adds a kubedrill context to your kubeconfig. Your current context stays as it was – kind-werkzeuge in this example.

$ kubedrill start
KubeDrill started: simulated Kubernetes v1.37.2 on https://127.0.0.1:16443 (pid 1413790)
Standalone kubeconfig: /home/ubuntu/.kubedrill/kubeconfig
Added context "kubedrill" to /home/ubuntu/.kube/config (current-context: kind-werkzeuge).

Try:
  kubectl --context kubedrill get nodes
  kubedrill challenge list

3 · Point kubectl at the simulator

Because your current context is not switched, you tell kubectl where to go. Three ways, the first is the safest:

# 1. Pass the context with every command (recommended)
kubectl --context kubedrill get nodes
# 2. Wrapper: always goes to the simulator, never to a real cluster
kubedrill kubectl get pods
# 3. Switch for good – remember to switch back later
kubectl config use-context kubedrill
$ kubectl --context kubedrill get nodes
NAME                      STATUS   ROLES           AGE   VERSION
kubedrill-control-plane   Ready    control-plane   1s    v1.37.2
kubedrill-worker          Ready    <none>          1s    v1.37.2
kubedrill-worker2         Ready    <none>          1s    v1.37.2

Tip to save typing: put alias kd='kubectl --context kubedrill' into your shell configuration, then kd get pods is enough.

4 · Practise as on a real cluster

Pods, Deployments, Services, Ingress, ConfigMaps and Secrets behave as in real Kubernetes: rollouts, rollbacks, endpoints, events. An image tag that does not exist ends in ImagePullBackOff, just like for real.

$ kubectl --context kubedrill create deployment web --image=nginx:1.27 --replicas=3 --port=80
$ kubectl --context kubedrill expose deployment web --port=80
$ kubectl --context kubedrill set image deployment/web nginx=nginx:1.28
$ kubectl --context kubedrill rollout status deployment/web
$ kubectl --context kubedrill rollout undo deployment/web
$ kubectl --context kubedrill run kaputt --image=nginx:9.99
$ kubectl --context kubedrill get pods
NAME     READY   STATUS             RESTARTS   AGE
kaputt   0/1     ImagePullBackOff   0          5s

Anything that would need a running process is refused with a clear message:

$ kubectl --context kubedrill exec nginx -- ls
error: unable to upgrade connection: exec is not available in the simulator: containers are
simulated and no processes run. Use 'kubectl logs', 'kubectl describe' and 'kubectl get events'
to inspect workloads.

5 · Solving a challenge

Challenges inject a fault into the cluster. You find it with kubectl, fix it and have the result checked. The next section shows the whole flow.

6 · Stop, resume, start over

$ kubedrill stop
KubeDrill stopped (pid 1413790). State saved to /home/ubuntu/.kubedrill/state.json.
The "kubedrill" context stays in your kubeconfig for the next start; `kubedrill kubeconfig remove` deletes it.
$ kubedrill start          # everything is back
$ kubedrill reset
Simulated cluster reset: all workloads, challenge state and events were removed.

stop saves the state, start restores it. reset deletes everything you created and your challenge progress.

A challenge step by step

Using service-selector as the example: the pods are running, but the Service cannot find them.

  1. Look at the list and start a challenge. Without an ID the first unsolved one starts.

    $ kubedrill challenge list
    ID                     DIFFICULTY    MIN  STATUS  TITLE
    crashloop-missing-env  beginner      10           CrashLoopBackOff: the API exits right after starting
    image-pull-backoff     beginner      10           Rollout stuck: the new image cannot be pulled
    missing-configmap      beginner      8            CreateContainerConfigError: missing ConfigMap
    service-selector       beginner      8            Service without endpoints
    ingress-wrong-port     intermediate  10           Ingress returns 503: backend port mismatch
    pending-resources      intermediate  10           Pending forever: insufficient resources
    readiness-probe        intermediate  12           Running but never Ready: failing readiness probe
    $ kubedrill challenge start service-selector
    Challenge started: Service without endpoints  [beginner]
    ID: service-selector
    
      The pods of "shop-frontend" are Running and Ready, but requests to the
      Service "shop-frontend" in namespace "default" fail: nobody answers.
    
      Find out why the Service does not route traffic and fix it.
      Run `kubedrill challenge check` when done.

    MIN is the estimated duration in minutes.

  2. Investigate – with plain kubectl. The Service has no endpoints:

    $ kubectl --context kubedrill get endpoints shop-frontend
    NAME            ENDPOINTS   AGE
    shop-frontend   <none>      0s
  3. Stuck? Hints are graded; each call shows the next one. kubedrill challenge status shows the task, the hints and the current state of the success criteria.

    $ kubedrill hint
    Hint 1/3:
      A Service forwards traffic to its endpoints. Look at them: `kubectl get endpoints shop-frontend`
      (or `kubectl describe service shop-frontend`).
    
    Still stuck? `kubedrill hint` shows hint 2.
  4. Find the cause and fix it. Here: a typo in the Service selector.

    $ kubectl --context kubedrill get svc shop-frontend -o jsonpath='{.spec.selector}'
    {"app":"shop-frontnd"}
    $ kubectl --context kubedrill get pods --show-labels
    NAME                             READY   STATUS    RESTARTS   AGE   LABELS
    shop-frontend-5b8cc996bf-j8lg8   1/1     Running   0          8s    app=shop-frontend,...
    $ kubectl --context kubedrill patch svc shop-frontend -p '{"spec":{"selector":{"app":"shop-frontend"}}}'
    service/shop-frontend patched
  5. Have it checked. The cluster state is evaluated, not the commands you used – any correct fix counts.

    $ kubedrill challenge check
    Success criteria:
      [x] Service shop-frontend has both frontend pods as ready endpoints  (2 ready endpoint(s))
      [x] Deployment shop-frontend is still available  (replicas=2 updated=2 available=2 desired=2)
    
    Solved! Well done – you fixed it on your own (1 hint(s) used).
  6. End the challenge. The cluster returns to its state before the challenge; with --keep it stays as it is.

    $ kubedrill challenge stop
    Challenge "service-selector" ended: solved on your own.
    The cluster was restored to the state before the challenge.

Got stuck?

  • kubedrill challenge reset restores the broken starting point if you went down the wrong path. Hints already revealed stay visible.
  • kubedrill solve shows the diagnosis, root cause, fix and the matching commands. The cluster is not changed – you type the fix yourself, and the result counts as “completed with help”.

All commands

CommandWhat it does
kubedrill startStart the simulator in the background and add the kubedrill context
kubedrill stopStop the simulator and save its state
kubedrill statusShow address, process, kubeconfig and the active challenge
kubedrill doctorCheck kubectl, server and kubeconfig
kubedrill resetEmpty the cluster: delete your resources and challenge progress
kubedrill kubectl …kubectl that is guaranteed to talk only to the simulator
kubedrill challenge listAll challenges with difficulty, duration and status
kubedrill challenge start [id]Start a challenge (without an ID: the first unsolved one)
kubedrill challenge statusTask, hints and the state of the success criteria
kubedrill hint [--level N]Show the next hint or a specific one
kubedrill challenge checkCheck the result (exit code 1 while unsolved)
kubedrill challenge resetRestore the broken starting point of the challenge
kubedrill solveShow the solution without changing the cluster
kubedrill challenge stop [--keep]End the challenge and restore the previous state (or keep it)
kubedrill challenge validate DATEIValidate your own scenario files
kubedrill kubeconfig removeRemove the kubedrill context from the kubeconfig
kubedrill versionPrint versions

Useful options for kubedrill start: --port (a port other than 16443), --fresh (start without the saved state), --image-check=off (fully offline), --set-current-context (switch the context right away), --scenarios DIR (your own challenges).

Troubleshooting

kubectl shows my real cluster instead of the simulator.
Your current context is a different one. Add --context kubedrill, use kubedrill kubectl or switch with kubectl config use-context kubedrill. kubectl config current-context shows where commands go.
kubedrill kubectl rejects --context.
On purpose: the wrapper always talks to the simulator only and rejects options such as --context, --kubeconfig or --server, so a real cluster is never hit by accident.
Port 16443 is already in use.
Start on a different port, for example kubedrill start --port 17443. The kubedrill context is updated to match.
I have no internet connection.
Start with kubedrill start --image-check=off. KubeDrill then does not check image tags online; everything else works offline anyway.
exec, port-forward or top do not work.
No processes run in the simulator. Use logs, describe and get events – the same tools you use to find real faults.
I want to remove everything.
Run kubedrill stop, then kubedrill kubeconfig remove, and uninstall the package. The ~/.kubedrill folder holds state, keys and backups of your kubeconfig and can be deleted afterwards.

Your own challenges

A challenge is a YAML file: task, starting state, injected fault, success criteria and hints. Put it in ~/.kubedrill/scenarios/ or start with --scenarios DIR; kubedrill challenge validate checks it beforehand. Scenario guide

Challenges

Seven faults are built in. You can write your own scenarios in YAML, without any Go code.

IDLevelFault
image-pull-backoffBeginnerDeployment points to an image tag that does not exist; the rollout is stuck
crashloop-missing-envBeginnerApp exits because DATABASE_URL is missing
service-selectorBeginnerTypo in the Service selector, no endpoints
missing-configmapBeginnerReference to a missing ConfigMap → CreateContainerConfigError
readiness-probeIntermediateReadiness probe on a path that returns 404; Running but 0/1
pending-resourcesIntermediateMemory requests larger than any node → Pending
ingress-wrong-portIntermediateIngress backend points to a Service port that does not exist

Install

For macOS and Linux, amd64 and arm64. You also need kubectl; kubedrill doctor checks your setup.

# macOS (Homebrew)
brew install itdrills/tap/kubedrill
# Debian / Ubuntu (apt)
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://itdrills.github.io/kubedrill/gpg.key \
  | sudo gpg --dearmor -o /etc/apt/keyrings/kubedrill.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubedrill.gpg] https://itdrills.github.io/kubedrill/deb stable main" \
  | sudo tee /etc/apt/sources.list.d/kubedrill.list
sudo apt update
sudo apt install kubedrill
# Fedora / RHEL / Rocky / Alma (dnf)
sudo curl -fsSL -o /etc/yum.repos.d/kubedrill.repo https://itdrills.github.io/kubedrill/kubedrill.repo
sudo dnf install kubedrill
# then
kubedrill start
kubectl --context kubedrill get nodes

Updates arrive with brew upgrade, apt upgrade or dnf upgrade. The package repositories are signed. Binary with checksum and building from source: Installation page · Releases

What the simulator can't do

For everything that needs real pods, a real network and real nodes, there are the courses – there you work on a real cluster. Install Kubernetes locally

Early release

KubeDrill v0.1.0

Free and open source under the Apache License 2.0. Feedback and challenge ideas are welcome as an issue on GitHub.

More