Warnings

1 min read

Answer questions about Kubernetes Events, as the API returns them (core/v1 or events.k8s.io/v1), passed as a list or an EventList. Only Warning events count, so a caller can pass all of an object’s events.

Reference

FunctionDescription
firstWarningReturns the message of the first Warning event; "" when there is none.
hasWarningsReports whether any of the events is a Warning.
warningCountReturns the number of Warning events.
warningMessagesReturns the message of each Warning event, in order.
warningReasonsReturns the reason of each Warning event, in order.

Functions

firstWarning

firstWarning returns the message of the first Warning event; "" when there is none.

{{ firstWarning .events }}  → "Failed to pull image registry.example.com/web:2.0: not found"

hasWarnings

hasWarnings reports whether any of the events is a Warning.

{{ hasWarnings .events }}

warningCount

warningCount returns the number of Warning events.

{{ warningCount .events }}  → 2

warningMessages

warningMessages returns the message of each Warning event, in order.

{{ warningMessages .events }}
→ [Back-off restarting failed container Liveness probe failed]

warningReasons

warningReasons returns the reason of each Warning event, in order.

{{ warningReasons .events }}  → [Failed BackOff]