Sub topic 6
What events are and how to read their fields
This chapter assumes you can run kubectl get and kubectl describe, and that you know what Pods, Deployments, and Nodes are. Status tells you the current state of an object. Events tell you what happened to it on the way there.
What an event is
An event is a small API object (kind Event) that a controller or the kubelet creates to record something that happened to another object. The scheduler writes an event when it places a Pod. The kubelet writes one when it pulls an image or kills a container.
Events differ from status in three ways:
- Status describes the present. An event describes a moment.
- Events are informational. No controller reads them to decide what to do.
- Events are short-lived. By default they are kept for about an hour (the chapter on retention covers this).
The object an event is about is called the involved object, or the regarding object in the newer API.
Where to see events
kubectl describe prints the events for one object in its Events section at the bottom. The get command also shows the object's one-line summary.
kubectl get pod web-0 -o wide
kubectl describe pod web-0The Events section of describe looks like this:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m default-scheduler Successfully assigned default/web-0 to node-1
Normal Pulling 3m kubelet Pulling image "nginx:1.27"
Warning BackOff 10s (x12 over 3m) kubelet Back-off restarting failed containerThe fields
| Field | Meaning |
|---|---|
| Type | `Normal` for expected progress, `Warning` for something that may need attention. These are the only two values. |
| Reason | A short, CamelCase code such as `Scheduled`, `Pulling`, `Failed`, or `BackOff`. It is meant for machines and for quick scanning. |
| Age | Time since the event last occurred. |
| From | The component that reported it, for example `default-scheduler` or `kubelet`. |
| Message | A human-readable explanation. It often holds the detail you need, such as an error from the container runtime. |
| Object | The involved object. `describe` leaves this out because it is already filtered to one object. |
Repeated events
Look at the Age column in the last line above: 10s (x12 over 3m). The cluster does not create twelve separate events for twelve identical failures. It groups identical ones into a single event and increases its count. The text means the event last happened 10 seconds ago, occurred 12 times, and first appeared 3 minutes ago.
This keeps the event store small. It also means a count can hide the exact timing of each repeat.
Reading events in order
Read the events from top to bottom as a story. A healthy start usually runs Scheduled, Pulling, Pulled, Created, Started. A failure breaks that sequence. If the story stops after Scheduled, the problem is on the node, such as the image pull. If there is no Scheduled event, the Pod was never placed.
Exercise
Exercise
A describe output shows Warning BackOff 10s (x12 over 3m) kubelet Back-off restarting failed container. What do 10s and (x12 over 3m) tell you, and which component reported it?
Show answer
The event last occurred 10 seconds ago. It has occurred 12 times, and the first occurrence was 3 minutes ago. Identical events are grouped into one with a count. The kubelet reported it, as shown in the From column.