How to view the IP addresses of all nodes in k8s?
To view the IP addresses of all Node nodes in the Kubernetes cluster, you can use the kubectl command-line tool to run the following command:
kubectl get nodes -o wide
This command will return a table containing detailed information about each node, including the node name, status, IP address, and other relevant information. Using the -o wide option will display more columns, including the node’s IP address.
Additionally, if you only want to obtain the IP address list of nodes without needing any other information, you can use the following command to extract the IP addresses of the nodes:
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}'
This command will provide a list of node IP addresses separated by spaces.
Please make sure kubectl is properly set up and connected to the Kubernetes cluster before executing these commands.