<p>My problem: i create ingress rule via kubernetes-client:</p>
<pre class="lang-java prettyprint-override"><code>try (InputStream is = IOUtils.toInputStream(crd, StandardCharsets.UTF_8)) {            
    client.load(is).inNamespace(namespaceName).createOrReplace();
}
</code></pre>
<p>Where <code>is</code> - yaml file with ingress rule like:</p>
<pre class="lang-yaml prettyprint-override"><code>spec:
  ingressClassName: nginx
  rules:
    - host: {{host}}
      http:
        paths:
          - backend:
              service:
                name: {{service_name}}
                port:
                  number: 80
            path: /
            pathType: ImplementationSpecific
</code></pre>
<p>But in my task i need ensure that the rule is created, i need wait or check status in loop.
What is the best way to do it?</p>
<p>Thanx!</p>

aarexer
<p>I think you might be able to do it with <code>waitUntilCondition</code>:</p>
<pre class="lang-java prettyprint-override"><code>try (KubernetesClient client = new KubernetesClientBuilder().build()) {
  Ingress ingress = client.network().v1().ingresses()
      .load(IngressRuleWaitUntilCondition.class.getResourceAsStream(&quot;/ingress-rule.yml&quot;))
      .get();

  client.resource(ingress)
      .inNamespace(&quot;default&quot;)
      .createOrReplace();

  client.network().v1()
      .ingresses()
      .inNamespace(&quot;default&quot;)
      .resource(ingress)
      .waitUntilCondition(i -&gt; !i.getSpec().getRules().isEmpty(), 2, TimeUnit.MINUTES);
}
</code></pre>
