Is it possible to get a list of pods that have status Running
from kubectl
?
Using an external command it would be:
kubectl get pods | grep Running
Can I ask this from kubectl
directly instead of string matching with grep or awk?
您可以使用golang模板: kubectl get pods --all-namespaces -o go-template --template '{{range .items}}{{if eq (.status.phase) ("Running")}}{{.metadata.name}}{{"\\n"}}{{end}}{{end}}'
当然, {{.metadata.name}}
可以用您需要的任何信息替换或扩展。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.