<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>

<p>As writing to EFS is too slow in your case, there is another option for AWS EKS - <code>awsElasticBlockStore</code>.</p>
<blockquote>
<p>The contents of an EBS volume are persisted and the volume is unmounted when a pod is removed. This means that an EBS volume can be pre-populated with data, and that data can be shared between pods.</p>
</blockquote>
<p><strong>Note</strong>: You must create an EBS volume by using aws ec2 create-volume or the AWS API before you can use it.</p>
<p>There are some restrictions when using an awsElasticBlockStore volume:</p>
<ul>
<li>the nodes on which pods are running must be AWS EC2 instances</li>
<li>those instances need to be in the same region and availability zone as the EBS volume</li>
<li>EBS only supports a single EC2 instance mounting a volume</li>
</ul>
<p>Check the <a href="https://kubernetes.io/docs/concepts/storage/volumes/#awselasticblockstore" rel="nofollow noreferrer">official k8s documentation page</a> on this topic, please.
And <a href="https://aws.amazon.com/premiumsupport/knowledge-center/eks-persistent-storage/" rel="nofollow noreferrer">How to use persistent storage in EKS</a>.</p>
