Kubernetes CKA sample exam question 120 with answer

Question
List name of all nodes as per below format and save the output in /tmp/node-names.txt file. The format should be:

NODE_NAME
node01
node02
Answer
You always need to use custom-columns output format if you have to define customized columns:
kubectl get nodes -o=custom-columns=NODE_NAME:.metadata.name
kubectl get nodes -o=custom-columns=NODE_NAME:.metadata.name > /tmp/node-names.txt
If you don’t need to include custom columns in the result - then jsonpath can be used