Kubernetes object creation time

2/21/2021

Is there a command/method to get the time elapsed from the instance a Kubernetes object creation command is launched (e.g., kubectl create -f mydeployment-pod.yaml), until the Kubernetes object (deployment/pod…) is fully created and in running/ready state.

-- Mazen Ezzeddine
kubernetes
kubernetes-pod

2 Answers

2/21/2021

No, but you can see the events and CreationTimestamp by kubectl describe deployments <deployment_name>

-- Sahadat Hossain
Source: StackOverflow

2/22/2021

As mentioned by @Sahadat: there is no native way of calculating that. However, you can use kubectl get events to see the CreationTimestamp, firstTimestamp and lastTimestamp. You can either request the output in yaml/json format by executing kubectl get events -o yaml or use custom columns and fields selectors to narrow down the output, for example:

kubectl get events -o custom-columns=FirstSeen:.firstTimestamp,LastSeen:.lastTimestamp,Created:.CreationTimestamp

That of course can be adjusted according to your needs.

-- Wytrzymały Wiktor
Source: StackOverflow