<p>I'm trying to find a way to trigger a memory dump when a container experiences an OOM exception. The problem is that when this happens, the container is restarted so we're unable to get a valid dump. I saw a <a href="https://danlebrero.com/2018/11/20/how-to-do-java-jvm-heapdump-in-kubernetes/" rel="noreferrer">similar article outlining how to do it in Java</a>, but I'm not sure if/how this can be translated to .NET Core. </p>

Goose
<p>You have 2 ways to do this. </p>

<p>For both ways to work, .Net Core needs to support a flag which tells it to dump on crash and a flag to pass it the path of where to dump.</p>

<ol>
<li><p>Have a sidecar with shared storage on the microservice pod. In the sidecar, have a script that monitors the storage and copies the files dumped there to a location like a s3. I guess this is the one mentioned in the Java link</p></li>
<li><p>Have a storage common storage attached to all the pods of a Microservice, something like a NFS, in amazon's case, EFS. Use that efs in your deployment and make the .Net dump to that storage. Then it's only a matter to getting the dump out which you can do via a debug pod or a jumphost attached to the EFS</p></li>
</ol>
