Kubernetes - 如何知道哪些 minions 正在托管 Pods

Kubernetes - How to know which minions are hosting Pods

我有一个 6 minion 集群,想知道在任何给定时间这些 minions 中有多少实际托管 pods。是否有特定的命令?现在我正在使用一个非常通用的命令。

kubectl get po | grep Running > RUNNING.txt
for i in `cat RUNNING.txt `; do kubectl describe po $i; done | grep "Started container with docker

"

有没有直接命令来获取我想要的信息?

只需添加-o wide:

kubectl get pod -o wide

此命令将打印所有具有 pods 运行 的节点:

kubectl get pods -o jsonpath='{range .items[*]}{.spec.nodeName} {end}' | tr " " "\n" | sort | uniq