<p>I'm using kubernetes-client/java api and I want to programmatically get the pod status of all the pods in all the namespaces. My code is based on this <a href="https://github.com/kubernetes-client/java/blob/master/examples/src/main/java/io/kubernetes/client/examples/WatchExample.java" rel="noreferrer">example on Kubernetes java library</a>.</p>

<p>Here's a snippet of my code:</p>

<pre><code>Watch&lt;V1Pod&gt; watch = Watch.createWatch(
        client,
        api.listPodForAllNamespacesCall(
            null, null, null, null, limit,
            null, null, null, watchTrue,
            null, null),
        new TypeToken&lt;Watch.Response&lt;V1Pod&gt;&gt;() {}.getType());

for (Watch.Response&lt;V1Pod&gt; item : watch) {
    V1PodStatus podStatus = item.object.getStatus();
    String name = item.object.getMetadata().getName();
    String status = podStatus.getPhase();
    String kind = item.object.getKind();
    String details = podStatus.toString();

    System.out.printf("NAME: %s | KIND: %s | STATUS: %s | DETAILS: %n%s%n====================%n", name, kind, status, details);
}
</code></pre>

<p><strong>My question is this:</strong> Is <code>Watch</code> equivalent to an event handler? This code shows me a list of all the statuses of the pods, but will it automatically "push" more pod status events as they occur in realtime? Or is this only triggered once?</p>

BlueChips23
<p>Watch is designed to send continuous updates. If you run your program for a while and start/stop something, you will see new updates coming.</p>

<p>I'm not sure it's correct to call it an event handler though. It's a different pattern.</p>
