Skip to content

Performing Rolling Updates

If you’re wondering how to update an image and instance without dropping traffic, you’ve come to the right place. This guide assumes that you have an instance (or instances) running, and that the instance is part of a service group (see guide here).

In this guide we’ll be using a Go server as example:

Terminal window
git clone
cd examples/http-go1.21/

To do the rolling update, we’ll be using the deploy command’s --rollout flag. The flag allows for 3 values/policies:

  • remove: remove all existing (old) instances during the rollout.
  • keep: keep all existing (old) instances (old and new instances will get load balanced).
  • stop: stop all existing (old) instances, but do not remove them (you can start them up again with the kraft cloud inst start cmd).

Assuming your current instance is in a service group called my-service, the command would be as follows:

Terminal window
kraft cloud deploy --rollout remove -g my-service .

This single command will take care of:

  1. Creating as many new instances as there were old ones in the service group.
  2. Adding the new instances to the service group my-service.
  3. Immediately start load balancing between the old and new instances.
  4. Allow the old instances to complete any in-flight requests.
  5. Apply the relevant policy to the old instances.

During the phasing out of instances, you should see their state set to draining. To check this, run:

Terminal window
kraft cloud inst ls

After the last connection has closed or after 1 minute, whichever happens earlier, you should see the instances’ state change to stopped. At this point, the command will execute the relevant policy (remove, keep, stop).

Learn More

  • The load balancing guide
  • The service groups guide
  • The kraft cloud CLI reference, and in particular the services and scale sub-commands.
  • KraftCloud’s REST API reference, and in particular the section on service groups.