How to check the last time health check was run and the result for a Pod

9/18/2019

Is there a way to check the last time the liveness & readyness checks are done and what are the results of the same.

I check by doing

kubectl get pod my-pod -o yaml

The status section shows up like this but does not tell when the kubelet ran the health checks

  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```
-- randominstanceOfLivingThing
kubernetes
kubernetes-health-check

2 Answers

9/18/2019

A Pod is considered ready when all of its Containers are ready. One use of this signal is to control which Pods are used as backends for Services. When a Pod is not ready, it is removed from Service load balancers.The kubelet uses readiness probes to know when a Container is ready to start accepting traffic.

you can use kubectl describe pod liveness-exec to view the pod events. The output should indicates if the liveness probes have failed. You can get more details on this from Kubernetes.io

Additionally, a Pod has a PodStatus, which has an array of PodConditions through which the Pod has or has not passed.

Two of the elements are

  • The lastProbeTime field provides a timestamp for when the Pod condition was last probed.
  • The lastTransitionTime field provides a timestamp for when the Pod last transitioned from one status to another
-- Nur
Source: StackOverflow

9/18/2019

There is one closed issue for this.

And the pull request to expose result of liveness and readiness probes for all the pods as prometheus metrics is also merged.

Once this feature is officially released you can plot the result of liveness and readiness probes for all the pods.

For now what is supposed to be supported is answered by @nur.

Hope this helps.

-- mchawre
Source: StackOverflow