Reputation: 321
I want to be loop through the node names from the
kubectl get nodes
command and echo the names in Bash
.
Upvotes: 4
Views: 5675
Reputation: 18411
kubectl
provides various filters under -o
flag. you can see the list using kubectl --help
. One of the ways is to loop over it using for loop.
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=...
Upvotes: 13