<p>I am doing a rolling upgrade of specififc container of deployment using the fabric8 java client API</p>
<pre class="lang-java prettyprint-override"><code>client.apps().deployments().inNamespace(..)
       .withName(..)
       .rolling()
       .updateImage(...);
</code></pre>
<p>When observing k8s I can see the new pod being created and after the old one deleted as expected. How can I know the status of the upgrade programmatically?</p>
<p>I need to return response whether the upgrade succeeded or failed.</p>

<p>To check what is happening with deployment you can use Watcher:</p>
<pre><code>client.apps().deployments().inNamespace(&quot;default&quot;).watch(new Watcher&lt;Deployment&gt;() {
  @Override
  public void eventReceived(Action action, Deployment resource) {
    // Do stuff depending upon action
  }

  @Override
  public void onClose(KubernetesClientException cause) {

  }
});
</code></pre>
<p><a href="https://github.com/fabric8io/kubernetes-client/blob/c24152096f1a0438be1cd4978bea23a8dc185334/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Watcher.java#L46" rel="nofollow noreferrer">Action</a> is an enum, so you can check for <code>ERROR</code> and raise an exception:</p>
<pre><code>enum Action {
    ADDED, MODIFIED, DELETED, ERROR
  }
</code></pre>
<p><a href="https://github.com/fabric8io/kubernetes-client/blob/master/doc/CHEATSHEET.md#deployment" rel="nofollow noreferrer">Here</a> you can find more examples on what you can do with deployments</p>
