首页 > 解决方案 > 更详细的 Pod 状态监控

问题描述

我们的 Pod 通常会在状态中花费至少一分钟到数分钟Pending,这些事件通过kubectl describe pod xyield:

Events:
  Type    Reason     Age        From               Message
  ----    ------     ----       ----               -------
  Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned testing/runner-2zyekyp-project-47-concurrent-0tqwl4 to host
  Normal  Pulled     55s        kubelet, host  Container image "registry.com/image:c1d98da0c17f9b1d4ca81713c138ee2e" already present on machine
  Normal  Created    55s        kubelet, host  Created container build
  Normal  Started    54s        kubelet, host  Started container build
  Normal  Pulled     54s        kubelet, host  Container image "gitlab/gitlab-runner-helper:x86_64-6214287e" already present on machine
  Normal  Created    54s        kubelet, host  Created container helper
  Normal  Started    54s        kubelet, host  Started container helper

所提供的信息并不十分详细,无法准确了解正在发生的事情。

问题:

我们如何才能收集更详细的指标,以了解关于让 Pod 运行的确切情况和确切时间,以便解决哪个步骤确切需要多少时间?

特别感兴趣的是安装卷需要多长时间的指标。

标签: kuberneteskubernetes-pod

解决方案


检查 kubelet 和 kube 调度程序日志,因为 kube 调度程序将 pod 调度到一个节点,并且 kubelet 在该节点上启动 pod 并报告状态为就绪。

journalctl -u kubelet # after logging into the kubernetes node

kubectl logs kube-scheduler -n kube-system

描述 pod、deployment、replicaset 以获取更多详细信息

kubectl describe pod podnanme -n namespacename
kubectl describe deploy deploymentnanme -n namespacename
kubectl describe rs replicasetnanme -n namespacename

检查事件

kubectl get events -n namespacename

描述节点并检查应该准备好的可用资源和状态。

kubectl describe node nodename

推荐阅读