如何遍历 kubectl 的节点列表,回显每个节点名称?
How to loop over kubectl's node list, echoing each node name?
我想循环遍历来自
kubectl get nodes
命令并回显 Bash
.
中的名称
kubectl
在 -o
标志下提供各种过滤器。您可以使用 kubectl --help
查看列表。其中一种方法是使用 for 循环对其进行循环。
for node in $(kubectl get nodes -o name);
do
echo " Node Name: ${node##*/}"
echo "Type/Node Name: ${node}"
echo
done
-o, --output='': Output format. One of:
json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...
我想循环遍历来自
kubectl get nodes
命令并回显 Bash
.
kubectl
在 -o
标志下提供各种过滤器。您可以使用 kubectl --help
查看列表。其中一种方法是使用 for 循环对其进行循环。
for node in $(kubectl get nodes -o name);
do
echo " Node Name: ${node##*/}"
echo "Type/Node Name: ${node}"
echo
done
-o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...