Rollouts
A rollout replaces a set of running instances with new instances, for example to deploy a new version of your app.
The unikraft CLI creates the new instances, stops the old instances, and deletes the old instances when the new instances run.
Starting a rollout
Add --rollout to unikraft instance create or unikraft run:
Code
unikraft instance create needs --autostart.
unikraft run starts instances by default, so it doesn't need the flag.
By default, the rollout replaces the instances of the service group in --service, one at a time.
For each old instance, the CLI creates and starts a new instance.
When the new instance runs, the CLI drains the connections of the old instance and stops it.
At the end, the CLI deletes the old instances.
The rollout creates one new instance for each old instance, and gives each new instance a generated name. The service group sends traffic to the old and the new instances while the rollout runs, so the service stays available.
If no instance matches, the CLI creates the new instance without a rollout.
Add --dry-run to see the instances that a rollout replaces, in the replaces field.
Options
--rollout takes options as comma-separated <key>=<value> pairs:
| Option | Default | Description |
|---|---|---|
type | rolling | rolling replaces the instances one batch at a time, and recreate stops all old instances before the new instances start. |
by | service | service selects the instances of the service group in --service, and tags selects the instances that have all tags of the new instance. |
target | All | The service group, or the subset of the tags of the new instance, that selects the old instances. |
batch | 1 | The number of instances that a rolling rollout replaces at a time. |
healthy-after | 0 | The time that each new batch must keep running before the rollout continues, for example 30s. |
drain-timeout | 30s | The maximum time that an old instance has to finish its connections before it stops, or 0 to stop it without a drain. |
A drain ends when the old instance has no more connections, so most stops take less time than drain-timeout.
batch doesn't work with type=recreate.
Replacing all instances at once
Use type=recreate when the old and the new instances can't run at the same time, for example when they need sole access to a volume:
Code
The service doesn't answer requests between the stop of the old instances and the start of the new instances.
Selecting instances by tag
With by=tags, the rollout replaces the instances that have all the tags of the new instance, or the tags in target:
Code
This replaces all instances with the tag app-web, two at a time.
by=tags needs --metro and at least one --tag.
Health checks
The CLI waits until each new batch runs.
With healthy-after, it then waits for the given time, and checks again that the new instances still run.
The rollout fails if a new instance stops, restarts, or disappears before the rollout ends.
Each step of a rollout has a time limit of 15 minutes.
Failed and interrupted rollouts
If a step fails, or you interrupt the CLI with Ctrl+C, the CLI undoes the rollout.
It starts the old instances that it stopped, and deletes the new instances.
If the old instances don't start again, the CLI keeps the new instances and names them in the error.
The CLI runs the rollout itself. If the CLI ends without the chance to undo the rollout, for example because its machine shuts down, the old and the new instances stay. Check the instances of the service group, and delete the instances that you don't need.
Limitations
--rolloutdoesn't work with--nameor--replicas.by=serviceneeds an existing service group in--service.- A service group with autoscale can't have a rollout.
Learn more
- Load balancing: how a service group spreads traffic across its instances.
- Service groups: create the service group that a rollout replaces the instances of.
- Instances: how an instance drains its connections before it stops.
- The
unikraft instance createreference.