How to list Kubernetes recently deleted pods?

后端 未结 8 749
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 14:35

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

I am investigating bug. I have logs with my pod name. Th

相关标签:
8条回答
  • 2020-12-14 15:34

    If you want to see all the previously deleted pods and you are trying to fetch the previous pods.

    Command line: kubectl get pods

    in which you will get all the pod details, because every service has one or more pods and they have unique ip address

    Here you can check the lifecycle of pods and what phases of pod has. https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle

    and you can see the previous pod logs by typing a command: kubectl logs --previous

    0 讨论(0)
  • 2020-12-14 15:41

    As of today, kubectl get pods -a is deprecated, and as a result you cannot get deleted pods.

    What you can do though, is to get a list of recently deleted pod names - up to 1 hour in the past unless you changed the ttl for kubernetes events - by running:

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

    You can then investigate further issues within your logging pipeline if you have one in place.

    0 讨论(0)
提交回复
热议问题