kubectl rolling-update foo new_image. What interface API for rolling-update? Give an example for update new image? thanks!
If you run "kubectl help rollingupdate" you will get the answer to your question. (And new_image is a docker image.)
Additional documentation: https://github.com/kubernetes/kubernetes/tree/master/docs/user-guide/update-demo
If you check fabric8 rolling-update implementation (API mentioned below), they are creating a new replica set with a same deployed replica set spec and they increase the count in new replica set and wait for it to complete and then they decrease count from old deployed replica-set, thus maintaining availability.
private static void updateRc(KubernetesClient client){
System.out.println("updating rollinh");
// client.replicationControllers().inNamespace("default").withName("my-nginx").rolling().updateImage("nginx:latest");
client.extensions().replicaSets().inNamespace("default").withName("fgrg-73-nginxcontainer1-74-97775d4d8").rolling().updateImage("nginx:latest");
System.out.println("done");
}
One way to do rolling update via api is to first check if deployment.spec.updateStrategy
is RollingUpdate
and if not then update it after this just edit the deployment with the new image tag.
There is no API method for rolling-update, the CLI makes calls to the pod and replicationcontroller APIs behind the scenes to achieve a rolling update