kubernetes 列出所有正在运行的 pod 名称
问题描述:
我正在寻找列出所有 Pod 名称的选项
I looking for the option to list all pods name
没有awk(或cut)怎么办.现在我正在使用这个命令
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 模板选项来格式化输出以仅显示每个 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}}{{"
"}}{{end}}'