How to generate coredump for containers running with k8s
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_pattern2. 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-pathmount 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-dumpReference:
https://blog.csdn.net/u013774469/article/details/82595988