首页 > 解决方案 > 如何查看 k8s pod 启动所用的时间?

问题描述

我想知道在 Kubernetes 中启动我的 pod 所需的时间。我的 pod 有3 Init Containers9 actual Containers. 这是我到目前为止所尝试的:

在此处输入图像描述

问题: Kubernetes 是否提供任何方法来确定整个 pod 启动时间?

标签: kuberneteskubernetes-pod

解决方案


随着事情的开始,您的 pod 将通过一组PodConditions 进行

你可以使用:

kubectl get po <pod_name> -o yaml

通过这些不同的条件观察进展:

...
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2020-09-09T08:47:11Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2020-09-09T08:47:12Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2020-09-09T08:47:12Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2020-09-09T08:47:11Z"
    status: "True"
    type: PodScheduled
...

如果您想在 shell 中自动解析所有这些,我建议您yq 进行实际的 YAML 解析。


推荐阅读