I need to export memory dump from Aks Cluster and save it in some location
How can I do it? Is easy to export to a storage account? Exist another solution? Can someone give me an step y step?
EDIT: the previous answer was wrong, I didn't paid attention you needed a dump. You'll actually will need to get it from Boot Diagnostic or some command line:
This question is quite old, but let me nevertheless share how I realized it:
Linux has an internal setting called RLIMIT_CORE
which limits the size of the core dump you'll receive when your application crashes - this is what you find quite quickly.
Next, you have to define the location of where core files are saved, which is done in the file /proc/sys/kernel/core_pattern
. The given path can either be a relative file name (saved next to the binary which crashed), an absolute path (absolute to the mounted namespace) or - here is where it gets interesting - a pipe followed by an absolute path to an executable (application or script). This script will (according to the docs - see headline Piping core dumps to a program) be started as user and group root
- but furthermore, it will (according to this post in the Linux mailing list) also be executed in the global namespace - in other words, outside of the container.
If you are like me, and you do not have access to the image used for new nodes on your AKS cluster, you want to set these values using DaemonSets, a pod which runs once on every node.
Armed with all this knowledge, you can do the following:
/proc/sys/kernel/core_pattern
.|/bin/dd of=/core/%h.%e.%p.%t
(dd
will take the stdin
, the core file, and save it to the location defined by the parameter of
). Core files will now be saved at /core/
. The name of the file can be explained by the variables found in the docs for core files./core/
of the root namespace, we can mount our storage there - in my case Azure File Storage
. Here's a tutorial of how to mount AzureFileStorage.RestartPolicy
set to Always
. Since the job of your pod is done, and you don't want it to restart automatically, let it remain running using sleep infinity
.This writeup is almost a copy of what I discovered while contacting the support from Microsoft. Here's the thread in their forum, which contains an almost finished configuration for a DaemonSet.
I'll leave some links here which I used during my research:
Sidenote:
I could also just have mounted the AzureFileSystem into every container and set the value for /proc/sys/kernel/core_pattern
to just /core/%h.%e.%p.%t
but this would require me to mention the mount on every container. Going this way I could free the configuration of the pods of this administrative task and put it where it (in my opinion) belongs, to the initial machine setup.