Created
November 22, 2019 23:00
-
-
Save henkin/b5e9b047e13a3c0a95773339f16f1297 to your computer and use it in GitHub Desktop.
wait for k8s ip #k8s #gcp
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
#!/usr/bin/env bash | |
# Waits for kubernetes ingress to get an IP | |
# Usage: | |
# wait-k8s-ip.sh <ingressName> <namespace> | |
# eg: wait-k8s-ip.sh ingress-name my-app-dev | |
# Will timeout after 5minutes (5 * 60 tries * 1 sec wait = 300 secs) | |
external_ip="" | |
times=0 | |
while [ -z $external_ip ] && [ $times -lt 300 ]; do | |
external_ip=$(kubectl get ingress $1 -n $2 --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") | |
[ -z "$external_ip" ] && sleep 1 | |
((times++)) | |
done | |
[ -z "$external_ip" ] && echo "timeout" || echo $external_ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment