Search code examples
javakubernetesout-of-memorykubernetes-podheap-dump

How could be memory dump saved in kubernetes cluster after crashing?


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?


Solution

  • 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