kubectl get pods --field-selector status.phase!=Running
上面的命令将在上面列出所有 pod,而不是默认命名空间的运行状态。
如果您想在所有命名空间中运行命令并列出所有 PODS
kubectl get pods --field-selector status.phase!=Running --all-namespaces
如果要打印命名空间,还可以根据需要打印自定义列
kubectl get pod --field-selector status.phase!=Running -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NAMEDPACE:.metadata.namespace
最终命令以您期待列的方式
kubectl get pod --field-selector status.phase!=Running -o=custom-columns=POD_NAME:.metadata.name,STATUS:.status.phase,NAMEDPACE:.metadata.namespace,CONTAINER_NAME:.spec.containers[*].name