1

When JVM crashes with OutOfMemoryError there are some options to store a dump:

-XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath=./java_pid<pid>.hprof

but what does it happen in kubernetes cluster after crashing? It seems kubernetes will clean up everything related to the pod crushed? How can I save it?

J.J. Beam
  • 2,612
  • 2
  • 26
  • 55

1 Answers1

4

just mount it as a volume.

volumeMounts:
        - name: heap-dumps
          mountPath: /dumps
      volumes:
      - name: heap-dumps
        emptyDir: {}

How to do a java heap dump in K8s

Opri
  • 590
  • 2
  • 11
  • so does it mean it should be done on every pod running java application/microservice? – J.J. Beam Apr 27 '21 at 20:53
  • 1
    WIll this volume persist the pod destruction and new one creation? – lucasvc Nov 24 '22 at 09:26
  • If the pod moves to a different node, the data is lost. So this is not a fool-proof solution unless you have only one node in your cluster. – talonx Mar 16 '23 at 05:19