How to find the previous pod names after redeployment in kubernetes?

11/3/2020

I redeployed my application with helm upgrade, e.g.

helm upgrade myapp helm/myapp  --install --namespace=myapp --set image=myapp:latest

Then with

kubectl get pods

I can see new pods get started and old pods get terminated. I wonder once the old pods are terminated, and gone from kubectl get pods, can I still find their pod names somehow?

-- zyxue
kubernetes

1 Answer

11/17/2020

Nowadays $ kubectl get pods -a is deprecated, and as a result you cannot get deleted pods.

However you can get a list of recently deleted pod names - up to 1 hour in the past unless you changed the ttl for kubernetes events - by executing command:

$ kubectl get event -o custom-columns=NAME:.metadata.name | cut -d "." -f1

Take a look: deleted-pods.

For future consider auditing. Kubernetes auditing gives a security chronological set of records documenting the sequence of activities that have affected system by administrators, users or other components of the system.

-- Malgorzata
Source: StackOverflow