Last active
July 10, 2019 07:41
-
-
Save ReallyLiri/f2bb3e3e567b4b5099747ed58079c9d6 to your computer and use it in GitHub Desktop.
Get external IP of a service in GKE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# required vars: gcloud-api-key.json, $GCLOUD_PROJECT, $GCLOUD_ZONE, $CLUSTER_NAME, $SERVICE_NAME | |
gcloud auth activate-service-account --key-file gcloud-api-key.json | |
gcloud config set project $GCLOUD_PROJECT | |
gcloud config set compute/zone $GCLOUD_ZONE | |
lines=`gcloud container clusters list --filter NAME="$CLUSTER_NAME" | wc -l` | |
if [ $lines -eq 0 ] ; then echo "No deployed cluster for $CLUSTER_NAME" && exit 1 ; fi | |
gcloud container clusters get-credentials $CLUSTER_NAME | |
external_ip=$(kubectl get svc $SERVICE_NAME --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") | |
echo "IP for cluster $CLUSTER_NAME is $external_ip" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment