• Command: kubectl debug pod/my-pod -it --image=busybox • Use Case: Debug a running pod by creating a new container in the context of the original pod.
2. COPYING FILES FROM A POD
• Command: kubectl debug pod/my-pod -it --image=busybox -- copy-to=/tmp/my-pod-debug • Use Case: Copy files from a running pod to your local machine for analysis.
3. DEBUGGING PODS IN A DIFFERENT NAMESPACE
• Command: kubectl debug pod/my-pod --namespace=other- namespace -it --image=ubuntu • Use Case: Debug pods in a different namespace using a specific image.
4. INSPECTING NETWORK ISSUES
• Command: kubectl debug pod/my-pod -it --image=nicolaka/ netshoot • Use Case: Troubleshoot network-related issues within a pod.
5. DEBUGGING WITH A SPECIFIC SERVICE ACCOUNT
• Command: kubectl debug pod/my-pod -it --image=alpine -- serviceaccount=my-service-account • Use Case: Debug using a specific service account for necessary permissions and access. 6. DEBUGGING INIT CONTAINERS • Command: kubectl debug pod/my-pod --target=my-init- container -it --image=busybox • Use Case: Debug init containers in a pod.
7. DEBUGGING NODE-LEVEL ISSUES
• Command: kubectl debug node/my-node -it --image=ubuntu • Use Case: Create a debugging session at the node level for broader diagnostics.