How to perform Rolling update and Rollback of deployment in Kubernetes using fabric8 java client API?

6/6/2019

I'm using fabric8 java client library for kubernetes in my project. I am not able to find the best way to perform rolling update and rollback of deployment to previous version using their APIs.

I tried some of their APIs but don't think it is correct.

Config config = new ConfigBuilder().build();
KubernetesClient client = new DefaultKubernetesClient(config);

client.apps().deployments().inNamespace("default").withName("nginx").createOrReplace(deployment);

What is the best way to do it? Any help is much appreciated.

-- shreyas.k
fabric8
java
kubernetes

1 Answer

6/8/2019

I think you can do rolling update like this(available since v4.1.3):

     client.apps().deployments().inNamespace("default")
       .withName("nginx")
       .rolling()
       .withTimeout(5, TimeUnit.MINUTES)
       .updateImage("");
-- Rohan Kumar
Source: StackOverflow