Pods
Answer questions about a set of Pods, as the API returns them, passed as a list or a PodList: names, IPs, phases, nodes, readiness, restarts, and why containers are waiting or failed (CrashLoopBackOff, OOMKilled, ImagePullBackOff, …).
Reference
| Function | Description |
|---|---|
hasCrashingPod | Reports whether any container is failing now: waiting or terminated with a failure reason (CrashLoopBackOff, OOMKilled, ImagePullBackOff, …), or not running after restarting before. |
podByOrdinal | Returns the pod whose name ends in -<ordinal>, as StatefulSet pods are named (web-0, web-1, …); nil when none does. |
podContainerReasons | Returns the distinct reasons containers are waiting or terminated with, across all pods, in first-seen order. |
podContainerState | Returns the state (Running, Waiting, Terminated) of a named container in the pod at ordinal; "" when either is not found. |
podCount | Returns the number of pods. |
podCrashLoopDetected | Reports whether any container in the pods is crash looping: waiting with reason CrashLoopBackOff, or terminated with a non-zero exit code after restarting before, as it shows between back-offs. |
podCreateContainerErrorDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, CreateContainerError. |
podErrImagePullDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, ErrImagePull. |
podErrorDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, Error. |
podIPs | Returns the pods’ IP addresses; pods without one yet are skipped. |
podImagePullBackOffDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, ImagePullBackOff. |
podInvalidImageNameDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, InvalidImageName. |
podMaxRestarts | Returns the highest restart count of any pod (the sum over its containers). |
podNames | Returns the pods’ names, in order. |
podNodes | Returns the nodes the pods are scheduled on; pending pods are skipped. |
podOOMKilledDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, OOMKilled. |
podPhases | Returns each pod’s phase, in order. |
podPostStartHookErrorDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, PostStartHookError. |
podPreStartHookErrorDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, PreStartHookError. |
podRestartedWithin | Reports whether any container in the pods last terminated within window (“10m”, “1h”, “1d”), going by its last termination’s finishedAt. |
podRunContainerErrorDetected | Reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, RunContainerError. |
readyPodCount | Returns the number of pods whose Ready condition is True. |
Functions
hasCrashingPod
hasCrashingPod reports whether any container is failing now: waiting or terminated with a failure reason (CrashLoopBackOff, OOMKilled, ImagePullBackOff, …), or not running after restarting before. Init containers count. A container that is running again is not crashing, however often it restarted: restart counts only reset when the pod is replaced. For one that runs and crashes in turn, use podRestartedWithin.
{{ hasCrashingPod .pods }} → true
podByOrdinal
podByOrdinal returns the pod whose name ends in -<ordinal>, as StatefulSet pods are named (web-0, web-1, …); nil when none does.
{{ (podByOrdinal .pods 0).status.podIP }} → "10.0.0.1"
podContainerReasons
podContainerReasons returns the distinct reasons containers are waiting or terminated with, across all pods, in first-seen order.
{{ podContainerReasons .pods }} → [ImagePullBackOff]
podContainerState
podContainerState returns the state (Running, Waiting, Terminated) of a named container in the pod at ordinal; "" when either is not found.
{{ podContainerState .pods 0 "app" }} → "Running"
podCount
podCount returns the number of pods.
{{ podCount .pods }} → 3
podCrashLoopDetected
podCrashLoopDetected reports whether any container in the pods is crash looping: waiting with reason CrashLoopBackOff, or terminated with a non-zero exit code after restarting before, as it shows between back-offs.
{{ podCrashLoopDetected .pods }} → false
podCreateContainerErrorDetected
podCreateContainerErrorDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, CreateContainerError.
{{ podCreateContainerErrorDetected .pods }} → false
podErrImagePullDetected
podErrImagePullDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, ErrImagePull.
{{ podErrImagePullDetected .pods }} → false
podErrorDetected
podErrorDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, Error.
{{ podErrorDetected .pods }} → false
podIPs
podIPs returns the pods’ IP addresses; pods without one yet are skipped.
{{ podIPs .pods }} → [10.0.0.1 10.0.0.2]
podImagePullBackOffDetected
podImagePullBackOffDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, ImagePullBackOff.
{{ podImagePullBackOffDetected .pods }} → true
podInvalidImageNameDetected
podInvalidImageNameDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, InvalidImageName.
{{ podInvalidImageNameDetected .pods }} → false
podMaxRestarts
podMaxRestarts returns the highest restart count of any pod (the sum over its containers). 0 when there are no pods.
{{ podMaxRestarts .pods }} → 1
podNames
podNames returns the pods’ names, in order.
{{ podNames .pods }} → [web-0 web-1 web-2]
{{ join (podNames .pods) ", " }} → "web-0, web-1, web-2"
podNodes
podNodes returns the nodes the pods are scheduled on; pending pods are skipped.
{{ podNodes .pods }} → [node-1 node-2]
podOOMKilledDetected
podOOMKilledDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, OOMKilled.
{{ podOOMKilledDetected .pods }} → false
podPhases
podPhases returns each pod’s phase, in order.
{{ podPhases .pods }} → [Running Running Pending]
podPostStartHookErrorDetected
podPostStartHookErrorDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, PostStartHookError.
{{ podPostStartHookErrorDetected .pods }} → false
podPreStartHookErrorDetected
podPreStartHookErrorDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, PreStartHookError.
{{ podPreStartHookErrorDetected .pods }} → false
podRestartedWithin
podRestartedWithin reports whether any container in the pods last terminated within window (“10m”, “1h”, “1d”), going by its last termination’s finishedAt. It catches a container that runs for a while and crashes in turn, which looks healthy whenever it is running. An error when window is not a positive duration.
{{ podRestartedWithin .pods "10m" }} → false
podRunContainerErrorDetected
podRunContainerErrorDetected reports whether any container in the pods is waiting or terminated with reason, or last terminated with reason while not running, RunContainerError.
{{ podRunContainerErrorDetected .pods }} → false
readyPodCount
readyPodCount returns the number of pods whose Ready condition is True.
{{ readyPodCount .pods }} → 2