concept event in category kubernetes

This is an excerpt from Manning's book Kubernetes in Action, Second Edition.
If another issue is causing your pod not to run, or if you simply want to see more information about the pod, you can also use the kubectl describe pod command, as you did earlier to see the details of a worker node. If there are any issues with the pod, they should be displayed by this command. Look at the events shown at the bottom of its output. For a running pod, they should be similar to the following listing.
Listing 3.12 The events displayed by kubectl describe pod Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 25s default-scheduler Successfully assigned default/kubia-9d785b578-p449x to worker2 Normal Pulling 23s kubelet, worker2 Pulling image "luksa/kubia:1.0" Normal Pulled 21s kubelet, worker2 Successfully pulled image Normal Created 21s kubelet, worker2 Created container kubia Normal Started 21s kubelet, worker2 Started container kubia
Note
If you want to follow the exercises in this section in your own cluster, you may need to restart one of the nodes to ensure that the events are recent enough to still be present in etcd. If you can’t do this, don’t worry, and just skip doing these exercises yourself, as you’ll also be generating and inspecting events in the exercises in the next chapter.
Because Events are standalone objects, you can list them using kubectl get events, as shown in the next listing.
Listing 4.7 Listing events using kubectl get events $ kubectl get ev LAST SEEN TYPE REASON OBJECT MESSAGE 48s Normal Starting node/kind-worker2 Starting kubelet. 48s Normal NodeAllocatableEnforced node/kind-worker2 Updated Node A... 48s Normal NodeHasSufficientMemory node/kind-worker2 Node kind-work... 48s Normal NodeHasNoDiskPressure node/kind-worker2 Node kind-work... 48s Normal NodeHasSufficientPID node/kind-worker2 Node kind-work... 47s Normal Starting node/kind-worker2 Starting kube-...Note
The previous listing uses the short name ev in place of events.

This is an excerpt from Manning's book Kubernetes in Action.
Having a system that allows moving an application across the cluster at any time is also valuable in the event of server failures. As your cluster size increases, you’ll deal with failing computer components ever more frequently.
Kubernetes monitors your app components and the nodes they run on and automatically reschedules them to other nodes in the event of a node failure. This frees the ops team from having to migrate app components manually and allows the team to immediately focus on fixing the node itself and returning it to the pool of available hardware resources instead of focusing on relocating the app.
In addition to providing a consistent way of storing objects in etcd, it also performs validation of those objects, so clients can’t store improperly configured objects (which they could if they were writing to the store directly). Along with validation, it also handles optimistic locking, so changes to an object are never overridden by other clients in the event of concurrent updates.
Both the Control Plane components and the Kubelet emit events to the API server as they perform these actions. They do this by creating Event resources, which are like any other Kubernetes resource. You’ve already seen events pertaining to specific resources every time you used kubectl describe to inspect those resources, but you can also retrieve events directly with kubectl get events.
Maybe it’s me, but using kubectl get to inspect events is painful, because they’re not shown in proper temporal order. Instead, if an event occurs multiple times, the event is displayed only once, showing when it was first seen, when it was last seen, and the number of times it occurred. Luckily, watching events with the --watch option is much easier on the eyes and useful for seeing what’s happening in the cluster.
The following listing shows the events emitted in the process described previously (some columns have been removed and the output is edited heavily to make it legible in the limited space on the page).
Listing 11.9. Watching events emitted by the controllers
$ kubectl get events --watch NAME KIND REASON SOURCE ... kubia Deployment ScalingReplicaSet deployment-controller ➥ Scaled up replica set kubia-193 to 3 ... kubia-193 ReplicaSet SuccessfulCreate replicaset-controller ➥ Created pod: kubia-193-w7ll2 ... kubia-193-tpg6j Pod Scheduled default-scheduler ➥ Successfully assigned kubia-193-tpg6j to node1 ... kubia-193 ReplicaSet SuccessfulCreate replicaset-controller ➥ Created pod: kubia-193-39590 ... kubia-193 ReplicaSet SuccessfulCreate replicaset-controller ➥ Created pod: kubia-193-tpg6j ... kubia-193-39590 Pod Scheduled default-scheduler ➥ Successfully assigned kubia-193-39590 to node2 ... kubia-193-w7ll2 Pod Scheduled default-scheduler ➥ Successfully assigned kubia-193-w7ll2 to node2 ... kubia-193-tpg6j Pod Pulled kubelet, node1 ➥ Container image already present on machine ... kubia-193-tpg6j Pod Created kubelet, node1 ➥ Created container with id 13da752 ... kubia-193-39590 Pod Pulled kubelet, node2 ➥ Container image already present on machine ... kubia-193-tpg6j Pod Started kubelet, node1 ➥ Started container with id 13da752 ... kubia-193-w7ll2 Pod Pulled kubelet, node2 ➥ Container image already present on machine ... kubia-193-39590 Pod Created kubelet, node2 ➥ Created container with id 8850184 ... !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":28}]]"} !@%STYLE%@!
Imagine you prepared the YAML file containing the Deployment manifest and you’re about to submit it to Kubernetes through kubectl. kubectl sends the manifest to the Kubernetes API server in an HTTP POST request. The API server validates the Deployment specification, stores it in etcd, and returns a response to kubectl. Now a chain of events starts to unfold, as shown in figure 11.12.