Get the public IP addresses of nodes in a Kubernetes cluster:
kubectl get nodes -o wide
Get the public IP address, in an unnecessarily round-about way, of the node that a particular service is running on:
# Create an nginx deployment and service
kubectl create deployment web --image=nginx
kubectl expose deploy/web --type=NodePort --port=80
# Get pod ID
POD_ID=$(kubectl get pods -l app=web -o json | jq -r '.items[0].metadata.name')
# Get public IP of pod (works because nginx uses ubuntu)
kubectl exec -it $POD_ID -- apt-get update
kubectl exec -it $POD_ID -- apt-get install -y curl
PUBLIC_IP=$(kubectl exec -it $POD_ID -- curl ifconfig.me)
# Get nodePort
PUBLIC_PORT=$(kubectl get svc web -o json | jq -r '.spec.ports[0].nodePort')
echo "Public IP and port found... $PUBLIC_IP:$PUBLIC_PORT"