Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can kubectl describe show timestamp of pod events?

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?

like image 482
Jeremy Lewi Avatar asked Oct 19 '16 13:10

Jeremy Lewi


People also ask

How do I get a timestamp in Kubernetes?

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...

How do I check my Kubernetes pod events?

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.

Which command can be used to display the events for a pod?

Using kubectl describe pod <podname> for example will show events at the end of the output for the pod.

How do you sort kubectl events by time?

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.


1 Answers

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

like image 173
Ivan Stoiev Avatar answered Sep 19 '22 14:09

Ivan Stoiev