You need to enable JavaScript to run this app.
导航

容器 LogCollector 运行状态问题排查

最近更新时间2023.11.14 19:17:37

首次发布时间2023.03.24 17:39:35

如果容器的 LogCollector 心跳状态异常,往往需要首先排查对应 Pod 的 LogCollector 运行状态。如果运行状态为 Running,表示已成功安装 LogCollector,且 LogCollector 正常运行中。其他的 LogCollector 状态表示安装或运行异常,可参考本文档进行问题排查。

检查容器 LogCollector 运行状态

登录 Kubernetes 集群后,执行以下命令查看 LogCollector 的运行状态。

kubectl -n ${namespace}  get pods  | grep ${Daemonset}

在以下示例中,Daemonset 的名称是 log-collector,所属的 namespace 是 tls-log。

kubectl -n tls-log  get pods  | grep log-collector

如果回显信息显示 STATUS 字段值全部为 Running,表示当前 Kubernetes 集群已经成功安装 LogCollector,且运行状态正常。如果没有状态信息,或状态为 Evicted 等其他值,请参考处理方案进行进一步排查。
图片

处理方案

没有状态信息

问题现象:回显信息中 NAME 字段没有名为 “log-collector-xxxxx” 的 Pod。
图片
问题原因:该 Kubernetes 集群尚未安装 LogCollector。
处理方案

  1. 请参考安装 LogCollector(DaemonSet 方式)安装 LogCollector(Sidecar 方式)安装并运行 LogCollector。

    说明

    请确保按照日志服务所在地域和网络类型正确安装 LogCollector。

  2. 再次执行以下命令检查 LogCollector 运行状态。Status 显示为 Running 表示安装成功。
    kubectl -n tls-log  get pods  | grep log-collector
    

状态为 Evicted

问题现象:回显信息中,指定 Pod 的 Status 字段显示为 Evicted。
图片
问题原因:Pod 状态为 Evicted,说明节点存在污点,并且 LogCollector Daemonset 没有设置容忍度,导致 LogCollector Pod 无法调度到这个节点。污点及容忍度说明请参考 Kubernetes 官网文档
处理方案
为 LogCollector Daemonset 设置容忍度。假设节点存在一个键是 key1,值是 value1,效果是 NoSchedule的污点:key1=value1:NoSchedule,表示只有拥有和这个污点匹配的容忍度的 Pod 才能够被调度到这个节点。

  1. logcollector_ds.yaml 中为 LogCollector Daemonset 设置容忍度。
    logcollector_ds.yaml 中的 spec.template.spec 部分,添加以下容忍度可以匹配节点的污点 key1=value1:NoSchedule,进而保证 LogCollector Pod 能够被调度到这个节点。

    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      ......
    spec:
      ......
      template:
        ......
        spec:
          tolerations:
            - key: "key1"
              operator: "Equal"
              value: "value1"
              effect: "NoSchedule"
          ......
          containers:
            ......
    
  2. 再次执行以下命令检查 LogCollector 运行状态。Status 显示为 Running 表示安装成功。

    kubectl -n tls-log  get pods  | grep log-collector