0

I want to reload the deleted pods from the Kubernetes cluster . Is that possible?.

Is there a way to get some details about the Kubernetes pod that was deleted (stopped, replaced by new version).

Jonas
  • 121,568
  • 97
  • 310
  • 388
Riby Varghese
  • 101
  • 1
  • 9

2 Answers2

1

There is the option -p if with you want to check the logs from terminated pods.

-p, --previous=false: If true, print the logs for the previous instance of the container in a pod if it exists.

kubectl logs -p terminated-pod-name

The pod itself is ephemeral as well as its information unless you keep them with a persistent volume you are not able to recover such information once the pod is terminated/deleted. If you need to debug the pod you can use the describe.

kubectl describe pod pod-name
Daniel Marques
  • 1,249
  • 8
  • 17
  • do we have options for list all the pods which were deleted? – Riby Varghese Feb 11 '20 at 14:51
  • 1
    There is no a native command to check this, but you can run this command to check the events related with the name of objects that suffered some alteration, that includes the recent deleted/terminated pods: `kubectl get event -o custom-columns=NAME:.metadata.name | cut -d "." -f1`. – Daniel Marques Feb 11 '20 at 15:16
  • Also you can run this command: `kubectl get event --sort-by .metadata.name | cut -d "." -f1` is very similar but provides more information. – Daniel Marques Feb 11 '20 at 15:37
0

If you have a deployment object, you may fetch the last deployed versions or may rollback to previous versions based on the revision history value set in the deployment object.

As explained by @Bartosz Bilicki here How to list Kubernetes recently deleted pods? you can also fetch the data from the events.

I hope it helps.

Vaibhav Jain
  • 2,155
  • 5
  • 27
  • 41