首页 > 解决方案 > 如何跟踪 pod 等待启动的时间?

问题描述

我想了解 Pod 何时处于挂起状态,因为它们无法使用所需的资源来安排它们。有没有办法跟踪 Pod 在“挂起”或“已调度”状态下花费的时间?

标签: kubernetes

解决方案


lastTransitionTime在 pod 清单中的字段下方status.conditions显示 pod 在达到Running状态之前的每个中间状态的时间戳。

pod 转换的时间戳如下Initialized -> Ready -> ContainersReady -> PodScheduled

$ kubectl get pod coredns-fb8b8dccf-2lhl4 -n=kube-system -o json | jq '.status.conditions'
[
  {
    "lastProbeTime": null,
    "lastTransitionTime": "2019-07-22T19:58:17Z",
    "status": "True",
    "type": "Initialized"
  },
  {
    "lastProbeTime": null,
    "lastTransitionTime": "2019-07-22T19:58:56Z",
    "status": "True",
    "type": "Ready"
  },
  {
    "lastProbeTime": null,
    "lastTransitionTime": "2019-07-22T19:58:56Z",
    "status": "True",
    "type": "ContainersReady"
  },
  {
    "lastProbeTime": null,
    "lastTransitionTime": "2019-07-22T19:58:17Z",
    "status": "True",
    "type": "PodScheduled"
  }
]

一个 Pod 初始化后,通常处于Pending状态,直到它被调度(PodScheduled上面的状态)并达到Running状态。


推荐阅读