I recently learned that if you apply a deployment in Kubernetes and the pod crashes, you can still troubleshoot by creating a copy of that pod with a shell using the command 'kubectl debug'. It really helped me figure out that my rootless container couldn't write into root-owned volume mounts. Has anyone else tried this? What are your tips for debugging pods that crash?
3 Answers
This was definitely a game changer during my CKA studies! I wish they emphasized it more in the CKAD courses, though. Such a great tip to have!
For debugging distroless pods, you can still mount and execute binaries since all containers run under the host's kernel. Just make sure you have the right role permissions. You can use the command 'kubectl debug mypod -it --image=busybox' to create an interactive session.
Totally! The use of an ephemeral sidecar can make working with those types of pods much easier.
Yep, using kubectl debug is super handy! It lets you access a shell in a failing pod so you can check what's going wrong without having to restart it. It's a lifesaver for situations like this.

That's a good point! I found out that even with limited tools in your containers, you can run a debug container alongside to check what you need.