Reading Time: 3 minutes
Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

Azure Linux, a Linux-based operating system designed for cloud and container environments, is the new go to operating system for Azure Kubernetes Service (AKS). In this blog post, we will explore how to customize the location of core dump files in Azure Linux running on AKS. To ensure security and isolation, we will wrap the core dump customization process within a Kubernetes Daemon Set. We will also discuss the security concerns associated with running a privileged Daemon Set.

What is a Core Dump?

A core dump is a file that contains a snapshot of a program’s memory at the time of a crash or termination. Analysing core dumps can help identify the cause of the crash and facilitate debugging.

Customizing Core Dump Location

To customize the location of core dump files in Azure Linux on AKS, we can leverage sysctl. Let’s take a look at the command.

This command will modify the kernel parameter kernel.core_pattern. This parameter determines the pattern or format of the core dump file name when a program crashes and generates a core dump.

Let’s break down the components of the command and understand their meanings:

  • sysctl: This is a command-line utility used to view, modify, and configure kernel parameters in a running Linux system.
  • -w: This option is used to set the value of a kernel parameter.
  • kernel.core_pattern: This is the specific kernel parameter we are modifying. It specifies the pattern for generating the core dump file name.
  • =/tmp/core-%e-%s-%u-%g-%p-%t: This value is assigned to the kernel.core_pattern parameter. It sets the pattern for the core dump file name.

Now, let’s understand the placeholders within the pattern:

  • %h: Represents the hostname of the system where the core dump occurred.
  • %e: This placeholder is replaced with the executable (program) name that generated the core dump.
  • %s: This placeholder is replaced with the signal number that caused the program to crash.
  • %u: This placeholder is replaced with the UID (user ID) of the process that crashed.
  • %g: This placeholder is replaced with the GID (group ID) of the process that crashed.
  • %p: This placeholder is replaced with the PID (process ID) of the process that crashed.
  • %t: This placeholder is replaced with a timestamp indicating the time of the crash.

In the provided command, the core dump file name will follow the format: /tmp/core-{hostname}-{executable}-{signal}-{UID}-{GID}-{PID}-{timestamp}. The core dump files will be stored in the /tmp/ directory.

Implementing a Daemon Set

To ensure that all nodes in the Kubernetes cluster have access to the customized core dump location, we can use a Daemon Set. A Daemon Set ensures that a copy of the Pod is running on each node in the cluster.

Here’s an example of a Daemon Set manifest file (coredump-daemonset.yaml):

In the daemon set you may notice I have changed the command a bit to match what I needed. The core dump file created by the daemon set will look like: core.{hostname}.{executable}.{ PID}.{timestamp}. It will still be stored in the /tmp/ directory.

I have also added && sleep infinity to the end of the command. This is to ensure the daemon set pods continue to run and don’t keep restarting after they have configured the nodes.

You could take this process one step further and copy the crash dumps off to an Azure Storage account so if a node were scaled down or crashed, you would still be able to view the core dump file.

Security Concerns of Running a Privileged Daemon Set

Running a privileged Daemon Set raises security concerns, as it grants extensive privileges to the container running on each node. Here are a few important points to consider:

  • Privileged access: A privileged container has access to all system resources and can potentially compromise the security and stability of the host machine. Exercise caution when granting such privileges.
  • Container image security: Ensure that the container image used in the Daemon Set is from a trusted source and free from vulnerabilities. Regularly update the image to incorporate security patches and best practices.
  • Network access: Limit network access within the privileged container to only necessary resources. Restricting outbound traffic can help mitigate potential security risks.
  • Access controls: Apply appropriate RBAC (Role-Based Access Control) policies to restrict access to the Daemon Set and associated resources. Only authorized users or entities should have permissions to modify or interact with the Daemon Set.

Conclusion

Customizing the location of core dump files in Azure Linux on AKS can greatly facilitate debugging and analysis of system crashes. By wrapping this customization within a privileged Daemon Set, we ensure that all nodes in the cluster have access to the core dump files. However, it is crucial to consider the security implications of running a privileged Daemon Set and implement appropriate measures to mitigate risks.

Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *