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 )
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