如何列出 Kubernetes 最近删除的 pod? [英] How to list Kubernetes recently deleted pods?

查看:99
本文介绍了如何列出 Kubernetes 最近删除的 pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获取有关已删除(停止,由新版本替换)的 Kubernetes pod 的一些详细信息.

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

我正在调查错误.我有带有我的 pod 名称的日志.该 pod 不再存在,它被另一个(具有不同配置)所取代.新 Pod 与旧 Pod 驻留在相同的命名空间、复制控制器和服务中.

I am investigating bug. I have logs with my pod name. That pod does not exist anymore, it was replaced by another one (with different configuration). New pod resides in same namespace, replication controller and service as old one.

类似命令

kubectl  get pods
kubectl  get pod <pod-name> 

仅适用于当前的 pod(活动的或停止的).

work only with current pods (live or stopped).

如何获得有关旧 Pod 的更多详细信息?我想看

How I could get more details about old pods? I would like to see

  1. 创建时间
  2. 他们在创建时拥有哪些环境变量
  3. 为什么以及何时被阻止

推荐答案

截至今天,kubectl get pods -a 已被弃用,因此您无法获得已删除的 Pod.

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

您可以做的是获取最近删除的 pod 名称列表 - 最多过去 1 小时,除非您更改了 kubernetes 事件的 ttl - 通过运行:

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 |切-d."-f1

然后,您可以调查日志记录管道中的其他问题(如果您有的话).

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

这篇关于如何列出 Kubernetes 最近删除的 pod?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆