kubernetes列出所有正在运行的Pod名称
问题描述:
我正在寻找列出所有豆荚名称的选项
I looking for the option to list all pods name
如何不使用awk(或剪切).现在我正在使用此命令
How to do without awk (or cut). Now i'm using this command
kubectl get --no-headers=true pods -o name | awk -F "/" '{print $2}'
答
您可以使用kubectl内置的go templating选项来格式化输出,以仅显示每个Pod的名称.
You can use the go templating option built into kubectl to format the output to just show the names for each pod:
kubectl get pods --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'