Kubectl describe pods outputs the elapsed time since pod events occurred; e.g.
kubectl describe pods my-pod
outputs
Events:
FirstSeen LastSeen Count From SubobjectPath TypeReason Message
--------- -------- ----- ---- ------------- -------- ------ -------
21s 21s 1 {default-scheduler } Normal Scheduled Successfully assigned xlxqh to gf959ad9f-cwvs
19s 19s 1 {kubelet f959ad9f-cwvs} spec.containers{gpu-sample-devices} Normal Pulling pulling image "b.gcr.io/foo/sample:latest"
Is it possible to make kubectl describe instead output the actual time of the event?
Displaying the timestamp of each logged line You can display these timestamps by using the --timestamps=true option, as shown in the next listing. Listing 5.5 Displaying the timestamp of each log line $ kubectl logs kubia –-timestamps=true 2020-02-01T09:44:40.954641934Z Kubia server starting...
Accessing Kubernetes EventsRunning the kubectl describe command on specific cluster resources will list the events for that resource. A more generic way of doing this is by running the kubectl get events command, which lists the specific resources' events or the entire cluster.
Using kubectl describe pod <podname> for example will show events at the end of the output for the pod.
To sort events by time using kubectl, login into the Ubuntu 20.04 system. After that, navigate the command line terminal by searching in either application or using the “Ctrl+Alt+T” shortcut key. Once opened, start the minikube cluster in it by executing the cited below command in the terminal shell.
You could use a combination of custom columns and fields selector - provided by kubectl - on event objects. Example:
$ kubectl get events -o custom-columns=FirstSeen:.firstTimestamp,LastSeen:.lastTimestamp,Count:.count,From:.source.component,Type:.type,Reason:.reason,Message:.message \
--field-selector involvedObject.kind=Pod,involvedObject.name=my-pod
FirstSeen LastSeen Count From Type Reason Message
2020-01-21T16:30:25Z 2020-01-21T16:30:25Z 1 default-scheduler Normal Scheduled Successfully assigned my-pod to 10.10.1.3
2020-01-21T16:30:26Z 2020-01-21T16:30:26Z 1 kubelet Normal Pulling Pulling image "my-image"
2020-01-21T16:30:26Z 2020-01-21T16:30:26Z 1 kubelet Normal Pulled Successfully pulled image "my-image"
2020-01-21T16:30:26Z 2020-01-21T16:30:26Z 1 kubelet Normal Created Created container my-container
2020-01-21T16:30:27Z 2020-01-21T16:30:27Z 1 kubelet Normal Started Started container my-container
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With