Skip to content

Instantly share code, notes, and snippets.

@rkuzsma
Created January 5, 2017 03:33
Show Gist options
  • Save rkuzsma/2450c1cfe5b27ae2344c0c1c2c769323 to your computer and use it in GitHub Desktop.
Save rkuzsma/2450c1cfe5b27ae2344c0c1c2c769323 to your computer and use it in GitHub Desktop.
Get external IP address of Kubernetes nodes
#!/bin/bash
kubectl get nodes --selector=kubernetes.io/role!=master -o jsonpath={.items[*].status.addresses[?\(@.type==\"ExternalIP\"\)].address}
@ominidx
Copy link

ominidx commented Oct 21, 2021

kubectl get nodes -o wide | awk '{print $7}'

@h0jeZvgoxFepBQ2C
Copy link

is it possible to get this somehow as an environment variable in a deployment?

Like following from the downward API?

            - name: K8S_HOST_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment