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:
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 thekraft cloud inst start
cmd).
Assuming your current instance is in a service group called my-service
, the
command would be as follows:
This single command will take care of:
- Creating as many new instances as there were old ones in the service group.
- Adding the new instances to the service group
my-service
. - Immediately start load balancing between the old and new instances.
- Allow the old instances to complete any in-flight requests.
- 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:
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.