0

Is it possible to run a linux command against a process which is running inside a kubernetes pod. Example: I want to grab heapdumps on a java process running inside a k8 pod. The pod comes with minimal installation and does not have that much disk space either, so I want to run jmap command from local machine (pointing to k8 cluster). Thanks.

Jonas
  • 121,568
  • 97
  • 310
  • 388
colossal
  • 529
  • 1
  • 5
  • 22

2 Answers2

0

kubectl exec did it. It allows to run any command inside the container. For example:

kc exec <POD_NAME> -- jmap -dump:live,format=b,file=heapdump.bin <pid>
colossal
  • 529
  • 1
  • 5
  • 22
0

As I have already mentioned in the comments, what you can use is the kubectl exec command:

Execute a command in a container.

Usage:

$ kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]

The kubectl exec command is a tool that allows you to inspect and debug your applications, by executing commands inside your containers.

If you need more details and examples regarding how to use it, I recommend these two guides:

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37