How to wait until Kubernetes assigned an external IP to a LoadBalancer service? : <p>Creating a <a href="http://kubernetes.io/v1.1/docs/user-guide/services.html#type-loadbalancer" rel="noreferrer">Kubernetes LoadBalancer</a> returns immediatly (ex: <code>kubectl create -f ...</code> or  <code>kubectl expose svc NAME --name=load-balancer --port=80 --type=LoadBalancer</code>).</p>

<p>I know a manual way to wait in shell:</p>

<pre><code>external_ip=""
while [ -z $external_ip ]; do
    sleep 10
    external_ip=$(kubectl get svc load-balancer --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}")
done
</code></pre>

<p>This is however not ideal:</p>

<ul>
<li>Requires at least 5 lines Bash script.</li>
<li>Infinite wait even in case of error (else requires a timeout which increases a lot line count).</li>
<li>Probably not efficient; could use <code>--wait</code> or <code>--wait-once</code> but using those the command never returns.</li>
</ul>

<p>Is there a better way to wait until a service <em>external IP</em> (aka <em>LoadBalancer Ingress IP</em>) is set or failed to set?</p>
