0
0
Kubernetesdevops~20 mins

Debugging with kubectl debug in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kubectl Debug Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of kubectl debug creating ephemeral container
What is the output when running this command to add an ephemeral debug container to a running pod named webapp in namespace prod?
Kubernetes
kubectl debug -n prod -it webapp --image=busybox --target=webapp -- sh
Aephemeralcontainers "webapp-debugger" created in pod webapp
BPod/webapp created in namespace prod
CError from server (NotFound): pods "webapp" not found
DWarning: image busybox not found locally, pulling...
Attempts:
2 left
💡 Hint
Think about what kubectl debug does when adding ephemeral containers.
Troubleshoot
intermediate
2:00remaining
Troubleshooting kubectl debug failure due to missing target
You run kubectl debug -it mypod --image=busybox --target=app but get an error. What is the most likely cause?
AThe image busybox is not available in the cluster
BThe pod mypod does not exist in the current namespace
CThe container named app does not exist in pod mypod
Dkubectl debug requires --container flag instead of --target
Attempts:
2 left
💡 Hint
Check if the container name matches exactly inside the pod.
Configuration
advanced
2:00remaining
Configuring a pod to allow ephemeral containers
Which pod spec snippet correctly enables ephemeral containers for debugging?
A
spec:
  enableEphemeralContainers: true
B
metadata:
  annotations:
    ephemeral-containers.kubernetes.io/enabled: "true"
C
spec:
  ephemeralContainers:
  - name: debug
    image: busybox
DNo special configuration is needed; ephemeral containers are enabled by default
Attempts:
2 left
💡 Hint
Consider the default Kubernetes behavior for ephemeral containers.
Best Practice
advanced
2:00remaining
Best practice for debugging a pod with kubectl debug
What is the recommended approach to debug a running pod without disrupting its main containers?
ADelete the pod and recreate it with a debug container
BAdd an ephemeral container using kubectl debug
CModify the pod spec to add a permanent debug container
DUse kubectl exec to run commands inside the main container
Attempts:
2 left
💡 Hint
Think about non-disruptive debugging methods.
🧠 Conceptual
expert
2:00remaining
Understanding ephemeral container lifecycle
Which statement about ephemeral containers added via kubectl debug is TRUE?
AEphemeral containers are intended for temporary debugging and do not restart automatically
BEphemeral containers restart automatically if they exit
CEphemeral containers share the same lifecycle as the pod's main containers
DEphemeral containers require pod restart to be removed
Attempts:
2 left
💡 Hint
Consider how ephemeral containers behave compared to normal containers.