When we run kubectl get events
command output shows us details of cluster events like nginx pod has been killed or new deployment has been scheduled. so by running this command we can only see list of details of events but not in the sorted way. we can sort it by adding sort-by
parameter.
This command gets events sorted by specific field - sort by LAST SEEN column
1kubectl get events -n nexus --sort-by='.lastTimestamp'
To filter for a specific pod you can use a field-selector
parameter
1kubectl get event --namespace default --field-selector involvedObject.name=my-pod-x1y2z3
Output:
Disk 0 | Disk 1 | Disk 2 | Disk 3 | Disk 4 |
---|---|---|---|---|
LAST SEEN | TYPE | REASON | OBJECT | MESSAGE |
58m | Normal | SuccessfulDelete | replicaset/nexus-67ffc4d9dc | Deleted pod: nexus-67ffc4d9dc-gl5wr |
54m | Normal | Killing | pod/nexus-67ffc4d9dc-gl5wr | Stopping container nexus-app |
52m | Warning | FailedKillPod | pod/nexus-67ffc4d9dc-gl5wr | error killing pod: failed to “KillContainer” for “nexus-app” with KillContainerError: “rpc error: code = Unknown desc = Error response from daemon: No such container: 261fd100c0ce4a5654e9080c51803a70f829f0d2e0e7c4c9485edd94480e0554” |
44m | Normal | SuccessfulCreate | replicaset/nexus-6cf8b8d699 | Created pod: nexus-6cf8b8d699-thmbh |
41m | Normal | Scheduled | pod/nexus-6cf8b8d699-thmbh | Successfully assigned nexus/nexus-6cf8b8d699-thmbh to node-10-10-27-12 |
30m | Normal | ScalingReplicaSet | deployment/nexus | Scaled up replica set nexus-6cf8b8d699 to 1 |