【问题标题】:How to check the last time health check was run and the result for a Pod如何检查上次运行健康检查的时间和 Pod 的结果
【发布时间】:2020-01-18 22:13:02
【问题描述】:

有没有办法检查最后一次完成活动和就绪检查的时间以及相同的结果。

我通过做检查

kubectl get pod my-pod -o yaml

状态部分显示如下,但不告诉 kubelet 何时运行健康检查

  conditions:
  - lastProbeTime: null
    lastTransitionTime: 2019-09-17T10:38:20Z
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: 2019-09-17T10:38:35Z
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: 2019-09-17T10:38:35Z
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: 2019-09-17T10:38:20Z
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://<some link>
    image: nginx:latest
    imageID: someid
    lastState: {}
    name: nginx
    ready: true
    restartCount: 0
    state:
      running:
        startedAt: 2019-09-17T10:38:22Z
  hostIP: 172.18.3.8
  phase: Running```

【问题讨论】:

    标签: kubernetes kubernetes-health-check


    【解决方案1】:

    当所有容器都准备好时,Pod 被认为准备好了。此信号的一种用途是控制哪些 Pod 用作服务的后端。当 Pod 没有准备好时,它会从服务负载均衡器中移除。kubelet 使用就绪探针来了解容器何时准备好开始接受流量。

    您可以使用 kubectl describe pod liveness-exec 来查看 pod 事件。输出应指示活性探测是否失败。您可以从Kubernetes.io获得更多详细信息

    另外,一个 Pod 有一个 PodStatus,它有一个 PodConditions 的数组,Pod 已经通过或者没有通过。

    其中两个元素是

    • lastProbeTime 字段提供了 Pod 的时间戳 条件是最后一次探测。
    • lastTransitionTime 字段提供了 Pod 的时间戳 上次从一种状态转换到另一种状态

    【讨论】:

    • 当我描述时,我看到Readiness: http-get http://:http/actuator/health delay=0s timeout=1s period=10s #success=1 #failure=3 指向成功和失败的阈值。它不会告诉检查何时运行。
    • 转换告诉 Pod 的状态,而不是健康检查的结果。
    【解决方案2】:

    为此关闭了一个issue

    并且pull request 将所有 pod 的 liveness 和 readiness 探测结果公开为 prometheus 指标也被合并。

    此功能正式发布后,您可以绘制所有 pod 的 liveness 和 readiness 探测结果。

    现在应该由@nur 回答应该支持的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-16
      • 2022-01-18
      • 2014-10-02
      • 1970-01-01
      • 2016-10-13
      • 2020-06-25
      • 2021-09-13
      • 2019-11-03
      相关资源
      最近更新 更多