<p>I'm trying to use kubectl to wait for a service to get an external ip assigned. I've been trying to use the below just to get started</p>
<pre><code>kubectl wait --for='jsonpath={.spec.externalTrafficPolicy==Cluster}' --timeout=30s --namespace cloud-endpoints svc/esp-echo
</code></pre>
<p>But I keep getting the below error message</p>
<pre><code>error: unrecognized condition: &quot;jsonpath={.spec.externalTrafficPolicy==Cluster}&quot;
</code></pre>

user672009
<p>It is not possible to pass arbitrary <code>jsonpath</code> and there is already a <a href="https://github.com/kubernetes/kubernetes/issues/83094" rel="noreferrer">request for the feature</a>.</p>
<p>However, you can use a bash script with some sleep and monitor the service using other <code>kubectl</code> commands:</p>
<pre><code>kubectl get --namespace cloud-endpoints svc/esp-echo --template=&quot;{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}&quot;
</code></pre>
<p>The above command will return the external IP for the LoadBalancer service for example.</p>
<p>You can write a simple bash file using the above as:</p>
<pre><code>#!/bin/bash
ip=&quot;&quot;
while [ -z $ip ]; do
  echo &quot;Waiting for external IP&quot;
  ip=$(kubectl get svc $1 --namespace cloud-endpoints --template=&quot;{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}&quot;)
  [ -z &quot;$ip&quot; ] &amp;&amp; sleep 10
done
echo 'Found external IP: '$ip
</code></pre>
