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?
tl;dr; kubectl
does not allow describe
for events, nor offer a way to see the timestamp for each event occurrence.
kubectl
doesn't provide the timestamps for each occurrence of an event. If there is a single occurrence of an event, it will display the time elapsed since the event was seen. If there are multiple occurrences, it will only display the time since the first occurrence, and the time since the most recent occurrence.
Assumption: I couldn't find a design issue in the Kubernetes repo that indicated the design goal behind this, but I would assume the following: Nodes within the cluster could exist in multiple timezones, and you could be accessing the API from a totally different timezone than the cluster. As a result, showing an elapsed time tends to be much more indicative of when an issue occurred than a timestamp might be
You can if you use kubectl get events
. If you are trying to see the event timestamps, you could request the output in yaml/json format. Note that it will still only give you firstTimestamp
and lastTimestamp
for each event.
For example,
kubectl get events -o yaml
- apiVersion: v1
count: 1
firstTimestamp: 2016-10-19T23:02:47Z
involvedObject:
kind: Node
name: xyz
uid: 1e8f04e8-9650-11e6-b1ec-42010af00002
kind: Event
lastTimestamp: 2016-10-19T23:02:47Z
message: 'Node xyz event: Registered Node xyz
in NodeController'
metadata:
creationTimestamp: 2016-10-19T23:02:47Z
name: xyz
namespace: default
resourceVersion: "192"
selfLink: /api/v1/namespaces/default/events/xyz.147f113f8a7c7a80
uid: 26d053b6-9650-11e6-b1ec-42010af00002
reason: RegisteredNode
source:
component: controllermanager
type: Normal
This will give the raw resources of the Event
kind with timestamps. You can then narrow down on the events you are interested in.
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