How to kill a command process inside Kubernetes pod without crashing pod

1/4/2022

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!

-- robliv
java
kubernetes

1 Answer

1/4/2022

Starting from Kubernetes 1.19 you can debug running pods using Ephemeral Containers and kubectl debug command.

-- Vasili Angapov
Source: StackOverflow