Capturing Heap Dumps of stateless Kubernetes pods before container termination and export to AWS S3

Madeesha’s Tech Space
2 min readDec 2, 2022

Kubernetes supports executing commands before the container termination. So if we need to capture heap dump in the event of container termination to analyze an issue, we can use a Kubernetes feature called pre-stop hook. We can include the command that we need to execute before container termination to the pre-stop block inside the pod configuration.

lifecycle:
preStop:
exec:
command: ["/scripts/shutdown.sh"]

--

--