I want to be loop through the node names from the
kubectl get nodes command and echo the names in Bash.
I want to be loop through the node names from the
kubectl get nodes command and echo the names in Bash.
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=...