When restarted
kubectl describe pod your-pod-name
Look for a section like this:
State: Running
Started: Wed, 23 Jun 2021 23:52:05 +1000
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Wed, 23 Jun 2021 23:46:48 +1000
Finished: Wed, 23 Jun 2021 23:46:52 +1000
Ready: True
The interpretation of the above is as follows:
- The pod was terminated
Wed, 23 Jun 2021 23:46:52 +1000
after having started at Wed, 23 Jun 2021 23:46:48 +1000
, and is now running and ready, having been last started at Wed, 23 Jun 2021 23:52:05 +1000
A pull request has now been merged into the kubernetes 1.22 milestone, to add LAST RESTART
column to kubectl get pods
, and will be available once that's released - see here.
https://github.com/kubernetes/kubernetes/pull/100142
To see your current version - kubernetes version
(1.21 is the latest release as at 28th June 2021)
If restarted
kubectl get po [your-pod-name]
The pod was restarted at some stage if there is any number in the RESTARTS
column
Why restarted
kubectl describe pod [your-pod-name]
will show a Last State
which gives you a high level indication. To see what happened on the pod before it restarted, use kubectl logs your-pod-name --previous
. You can pipe this to a file for inspection e.g.
kubectl logs your-pod-name --previous > pod_previous_log.txt
(See also above under 'When restarted')