Cron Job - how to configure volume which is directly mapped to host

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: {Major:“1”, Minor:“15”, GitVersion:“v1.15.1”, GitCommit:“4485c6f18cee9a5d3c3b4e523bd27972b1b53892”, GitTreeState:“clean”, BuildDate:“2019-07-18T09:15:32Z”, GoVersion:“go1.12.5”, Compiler:“gc”, Platform:“linux/amd64”}
Cloud being used: Bare Metal
Installation method: NA
Host OS: Linux
CNI and version: NA
CRI and version: NA

My usecase / requirement is as below:

I have a cronjob which runs every 2 hrs in a pod which contains single-container running Java process. When the Java process creates a heap-dump due to some memory-leakage, I should be able to retrieve the heap-dump file from the container in a easier manner from known-location at host-level. Since the heap-dumps will be lost with the container, I would not be able to retrieve the generated heap-dumps. Instead, if the heap-dumps generated by the container are mapped and stored directly in host, I would be able to retrieve the same for troubleshooting even when the pod is not running.


What is the best possible way of realizing the above requirement ? I have checked possibility of using glusterfs volume but that would be too costly since the size of heap-dump files generated by JVM would be very large. What are better alternatives and if there is a “how-to” link which I can refer for testing, please point me to the same

Thanks in advance

Have you checked using a hostPath volume? If you want to write directly in the host (and don’t care about data location for the next run, like with local volume type), maybe hostPath can do the trick?

Thanks @rata, will check the hostPath option. Not sure how I missed this since we use this option in a different context.