如何使用Kubectl命令列出运行POD的容器及其信息

发布于 2025-02-05 05:51:55 字数 443 浏览 5 评论 0原文

当我们运行kubectl时,pod =>它列出了在吊舱内运行的容器的计数并重新启动计数。因此,我不确定哪个容器会重新启动。我要么需要登录到UI,要么使用Kubectl描述POD。

NAME       READY   STATUS    RESTARTS   AGE
test-pod   2/2   Running      5         14h

但是,我需要使用Kubectl命令符号来查看每个容器名称及其重新启动计数,如下所示。

NAME            STATUS    RESTARTS    AGE
container-1     Running      2         14h
container-2     Running      3         14h

如果有人帮助我,这将有所帮助。提前致谢!

When we run kubectl get pod => it is listing the count of containers running inside a pod and restart count. So I am not sure which container gets restarted. Either I need to login to UI or using kubectl describe pods.

NAME       READY   STATUS    RESTARTS   AGE
test-pod   2/2   Running      5         14h

But I need to see each container names and its restart count using kubectl command somethings as below.

NAME            STATUS    RESTARTS    AGE
container-1     Running      2         14h
container-2     Running      3         14h

It would be helpful if someone helps me on this. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任性一次 2025-02-12 05:51:55

您可以尝试这样的事情:

kubectl get pods <pod-name> -o jsonpath='{.spec.containers[*].name} {.status.containerStatuses[*].restartCount} {.status.containerStatuses[*].state}'

您将获得结果容器名称,restartcount和状态。
然后,您将能够根据需要将其格式化。

You can try something like this:

kubectl get pods <pod-name> -o jsonpath='{.spec.containers[*].name} {.status.containerStatuses[*].restartCount} {.status.containerStatuses[*].state}'

You will get in result container-name, restartCount and state.
Then you will be able to format it in such way as you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文