kuberneteskubectlgoogle-kubernetes-engine

How do I get the External IP of a Kubernetes service as a raw value?


I am running an application with GKE. It works fine but I can not figure out how to get the external IP of the service in a machine readable format. So i am searching a gcloud or kubectl command that gives me only the external IP or a url of the format http://192.168.0.2:80 so that I can cut out the IP.


Solution

  • Maybe not GKE as my clusters are on AWS, but I assume logic will be similar. When you kubectl get svc you can select output format and it will show more then just the "normal" get. For me, with ELB based services to het LB hostname it's enough to run ie. kubectl -n kube-system get svc cluster-nginx-ingress-controller -o json | jq .status.loadBalancer.ingress.hostname