<p>I need to persist the heap dump when the java process gets OOM and the pod is restarted.</p>
<p>I have following added in the jvm args</p>
<pre><code>-XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/dumps
</code></pre>
<p>...and emptydir is mounted on the same path.</p>
<p>But the issue is if the pod gets restarted and if it gets scheduled on a different node, then we are losing the heap dump. How do I persist the heap dump even if the pod is scheduled to a different node?</p>
<p>We are using AWS EKS and we are having more than 1 replica for the pod.</p>
<p>Could anyone help with this, please?</p>

Baitanik
<p>You will have to persists the heap dumps on a shared network location between the pods. In order to achieve this, you will need to provide persistent volume claims and in EKS, this could be achieved using an Elastic File System mounted on different availability zones. You can start learning about it by reading this <a href="https://www.eksworkshop.com/beginner/190_efs/efs-csi-driver/" rel="nofollow noreferrer">guide</a> about EFS-based PVCs.</p>
