How to generate coredump for containers running with k8s

ShuangLu
1 min readApr 21, 2019
1. Login into the machine running the container and change the output of dump file to the 'tmp/cores/' inside the container
echo "/tmp/cores/core.%p" > /proc/sys/kernel/core_pattern
2. Create yaml file to deploy pod.
Demo.yaml
apiVersion: v1
kind: Pod
metadata:
name: core-volume
spec:
nodeSelector:
kubernetes.io/hostname: <hostname>
volumes:
- name: core-path
hostPath:
path: /home/core-dump
containers:
- name: ubuntu
image: ubuntu:12.04
command: ["/bin/sleep","3600"]
volumeMounts:
- mountPath: /tmp/cores
name: core-path
mount the host path '/home/core-dump' to the '/tmp/cores'3. Create & login to the container. Manually abort the terminal.kill -s SIGSEGV $$4. Login to the host machine to check if the dump has been created
ls /home/core-dump
Reference:
https://blog.csdn.net/u013774469/article/details/82595988

--

--