更新时间:2025-08-07 GMT+08:00
分享

配置coredump能力

操作场景

创建/更新POD,支持通过Annotation(system.cci.io/coredump)配置内核的core_pattern内容,配置后容器内业务进程故障可通过生成的coredump文件进而分析实例程序异常原因

使用说明

创建pod时,请求的Annotation里增加core dump配置(system.cci.io/coredump :‘{“core_pattern”: “/var/cores/core.%h.%e.%p.%t”, “max_size”: 2048}’),如果没有指定max size,默认值是1024,在对应pod的容器里使用core dump能力

约束与限制

  • 请求里的system.cci.io/core_pattern字段必须以“/var/”开头且文件路径里不能有“|”字符
  • 需要用户确保配置的路径在容器中存在,推荐使用挂卷的方式持久化保存coredump文件

通过ccictl创建pod

您可以通过对工作负载添加annotations控制是否为当前pod开启coredump能力,如下所示。

apiVersion: cci/v2
kind: Deployment
metadata:
  annotations:
    description: ''
  labels: {}
  name: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      annotations:
        vm.cci.io/pod-size-specs: 2.00_4.0
        resource.cci.io/pod-size-specs: 2.00_4.0
        metrics.alpha.kubernetes.io/custom-endpoints: '[{api:'''',path:'''',port:'''',names:''''}]'
        system.cci.io/coredump: "{\"core_pattern\": \"/var/cores/core.%h.%e.%p.%t\",\"max_size\": 1024}"    # 配置开启coredump能力
        log.stdoutcollection.kubernetes.io: '{"collectionContainers": ["container-0"]}'
      labels:
        app: nginx
    spec:
      containers:
        - image: library/nginx:stable-alpine-perl
          name: container-0
          resources:
            limits:
              cpu: 2000m
              memory: 4096Mi
            requests:
              cpu: 2000m
              memory: 4096Mi
          command: []
          lifecycle: {}
      dnsPolicy: ''
      imagePullSecrets:
        - name: imagepull-secret
      dnsConfig: {}
  minReadySeconds: 0
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1

system.cci.io/coredump:Pod需要配置的coredump能力。

相关文档