kubernetes - 如何查看 k8s pod 启动所用的时间?
问题描述
我想知道在 Kubernetes 中启动我的 pod 所需的时间。我的 pod 有3 Init Containers
和9 actual Containers
. 这是我到目前为止所尝试的:
- 方法一:启动 pod 并监控,直到有 9/9 个容器在运行。在将给出启动时间的想法
AGE
。kubectl describe pod <pod_name>
- 方法 2:
kubectl events
使用orkubectl describe
命令参考 pod 的事件问题是并非所有容器都存在事件。此外,没有明确的方法可以了解 pod 处于READY
状态所花费的时间。
问题: Kubernetes 是否提供任何方法来确定整个 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 解析。
推荐阅读
- machine-learning - 偏差方差困境中的假设和不一致意味着什么?
- c# - 在htm之后删除剩余的网址?
- jquery - 使用jQuery将列表项内的文本输入值设置为另一个输入
- mysql - 参考表的 MySQL 查询性能
- python - 当 Chrome 浏览器通过 Python selenium 自动更新时,如何使用特定版本的 ChromeDriver
- javascript - 图表未从 JSON 数据中显示
- javascript - 如果具有特定文本的 div 不存在,则显示空数据
- vb.net - 打印错误:没有应用程序与此操作的指定文件关联
- javascript - 在 Lodash 中按条件合并两个 JSON 数组
- javascript - 如何使用演示应用程序创建 npm 包?