Three ways in with kubectl debug

  • 12 min
  • 6 steps
  • Operate and ship

Steps

0 of 6 done

payments runs a distroless image with no shell, invoicer crashes on start, and you need to look at a node. Attach an ephemeral container, debug a copy of the crashing pod, open a node debugging pod, and clean up after all three.

  1. Step 1 of 6

    payments runs a distroless image, so kubectl exec has no sh to start. Add an ephemeral busybox:1.37 container to it that targets the app container's process namespace. Leave out -it here; the lab only checks that the container is added.

    Checked against what your commands print.

  2. Step 2, not started: Make a copy of invoicer named invoicer-debug that adds a busybox:1.37 container called shell running sleep 3600, with process namespace sharing turned on so the shell can see the app's processes.

  3. Step 3, not started: Show the labels of every pod. The copy has none of invoicer's labels, which keeps it out of any Service that selects app=invoicer.

  4. Step 4, not started: Start a node debugging pod on kx-worker2 with busybox:1.37 that stays up by running sleep 3600.

  5. Step 5, not started: List the node debugging pod with its IP and node, and compare the IP with kx-worker2's INTERNAL-IP.

  6. Step 6, not started: Delete the copied pod and the node debugging pod. Leave payments and invoicer running: the ephemeral container stays in payments until the pod itself is deleted.

Lab terminal

Cluster time 1 minute 10 seconds
kind cluster kx, Kubernetes 1.37.
Each step is checked as you work.
​
Tab completes. Up and Down recall.
Type help for more.
Terminal keys

Enter runs the command. Tab completes, and the arrow keys recall earlier commands. Control C stops a watch. On an empty line, or after Escape, Tab moves focus out of the terminal.