One more simple doubt, when someone asks you below -- what should you write node . . .

Mayur Sharma:
One more simple doubt, when someone asks you below – what should you write node name or the what?
Question:

Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes-z3444kd9.json

My answer was, (which is wrong :stuck_out_tongue: )

kubectl get nodes -o=jsonpath='{.items[*].metadata.name}' > /opt/outputs/nodes-z3444kd9.json

Fernando Jimenez:

kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json

SaidBen:
I would use this >> kubectl get nodes -o=jsonpath='{.items[*].*metadata.name*}' > /opt/outputs/nodes-z3444kd9.json

Fernando Jimenez:
@SaidBen That’s assuming that what you are being asked is just the name of the nodes. I interpreted the question as it says. β€œGet the list of nodes …” How do you do that with the kubectl client?

kubectl get nodes

β€œβ€¦ in json format …”

kubectl get nodes -o json

β€œβ€¦ and store it in a file at /opt/outputs/nodes-z3444kd9.json”. Thus:

kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json