Question
List the InternalIP of all nodes of the cluster. Save the results to a file /root/Internal_IP_List.txt
Answer should be in the format: InternalIP of First Node{{ space }}InternalIP of Second Node (in a single line)
Answer
Get the environment details:
kubectl get nodes -o wide
we can see the IPs# Get ExternalIPs of all nodes
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
Navigate to that page, get the query and modify it in the following way:
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}'
Redirect the output to the file per requirements:
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}' > /root/Internal_IP_List.txt
Verify:
cat /root/Internal_IP_List.txt