<p>I am trying from a Java program to start a Kubernetes job and wait for its completion. However, there seems to have no equivalent of kubectl wait in the official Java API. My program is already using io.kubernetes.client and I don't want to rewrite everything on top of another API, or use two different Kubernetes API. I also want to avoid having to once again figure out how to call processes from Java to invoke kubectl, and moreover kubectl is not installed in the Docker image that will execute my Java program.
If there is a method to wait for a pod/job completion in the current Java Kubernetes API, why is it so hard to find and Google always directs me to kubectl-based posts?</p>
<p>I tried checking the io.kubernetes.client API. Only available &quot;wait&quot; method is the usual Object.wait which of course doesn't do what I need. Many searches on Google give results about kubectl or another Kubernetes Java API, something like fabline or labnine which I can hardly remember and make sense of.</p>

Eric Buist
<p>You can watch for an API resource, and when the appropriate state change happens you can run further statements.</p>
<p>For example like here: <a href="https://github.com/kubernetes-client/java/blob/master/examples/examples-release-15/src/main/java/io/kubernetes/client/examples/WatchExample.java#L48" rel="nofollow noreferrer">https://github.com/kubernetes-client/java/blob/master/examples/examples-release-15/src/main/java/io/kubernetes/client/examples/WatchExample.java#L48</a></p>
<p>When some change is happend on the Pod resource, you can catch the event and you get the current state of the Pod. You can check the current state is the state you are wanted and when it is, then run your logic.</p>
