如何在pod中的container 里面生成coredump 文件 并拷贝出来使用GDB debug

1. Update helm chart .

        a. Add a volume and initContainers  in the deployment .yaml

      volumes:
      - name: dumps
        emptyDir: {}
      initContainers:
      - name: {{ .Values.initContainers.coredumps.service.name }}
        image: "{{ .Values.global.registry.url }}/{{ .Values.imageCredentials.repoPath }}/{{ .Values.initContainers.coredumps.images.name }}:{{ .Values.initContainers.coredumps.images.tag }}"
        command: ['sh', '-c', 'ulimit -c unlimited; echo "{{ .Values.initContainers.coredumps.service.dst }}/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern;']
        securityContext:
          privileged: true

      b. Add volumeMounts for container which needs generate core dump in the deployment.yaml  .

volumeMounts:
- name: dumps
  mountPath: {{ .Values.initContainers.coredumps.service.dst }}

      c. Add following codes in value.yaml (image name is "docker pull registry.suse.com/suse/sles12sp4" then docker tag xxx bbb)

initContainers:
  coredumps:
    images:
      name: xxx
      tag: 1.xxx
    service:
      name: coredumps
      dst: /root/dumps

2. Debug model to build code and generate an image .

3. Update the image to deployment .

4. Check coredump file in the pod .

    a. "docker ps | grep ApplicationName"  to found container id .

    b. "docker inspect container id | grep dump" to found dir that docker volume map to local dir.

5. Copy core dump file to yourself dir .

6. "gdb application corefile" to gdb.

你可能感兴趣的:(MicroService,Docker,MicroService)