I have a K8s Deployment that runs a Linux Docker image with Java and executes a sh script command running a Java process that on pod startup and it fails shortly after starting, triggering a pod crash and re-creation. It's a Java issue and logs are not helpful so I want to stop it before it fails and explore the pod file system and environemnt.
If I just try to kill
the java PID the pod crashes instantly. Is there any way I can stop the Java process (without altering the program or sh script code) from inside the pod shell before it gets to the part of crashing, and not trigger a pod crash?
Thanks!
Starting from Kubernetes 1.19 you can debug running pods using Ephemeral Containers and kubectl debug
command.