Unisrv logoUnisrv.io
Service Primitives

Deployments

Replicas of one container image and the resources each gets.

A deployment is desired state: this image, this many replicas, these resources per instance. The control plane compares it with the instances that exist and fixes the difference.

The deployment declares three replicas of api:v2. Two instances are running, so the control plane launches one more until the actual state matches.

Rollouts

Change the config and instances are replaced one at a time. Stateless deployments start the new instance first. A volume only takes one writer, so those stop the old one first and run a replica short while they do.

A deployment with two replicas rolls from v1 to v2. Without a volume, each new instance starts before an old one stops, so two instances are always serving. With a volume, the old instance must stop first, so the deployment briefly runs one replica short.

Changing the image from v1 to v2, replicas = 2. Time runs left to right.

Placement

The control plane picks a node once, when an instance launches. It only considers your nodes that are active, not paused, and match the deployment's placement constraint. Among those it prefers the node running the fewest of this deployment's instances, then the one with the least memory allocated.

A constraint can require a CPU architecture (amd64, arm64) or an isolation mode (vm, container). Set it with a placement block or in the web console. Changing it replaces every instance.

Not yet: placing by region, or by tags you put on your own nodes.

Failures

  • Failed instances are replaced. Repeated failures stretch the wait between launches up to a cap, but retries never stop. A config change or an invalidation resets the wait.
  • Instances on a lost node are replaced. If a node stops reporting, its instances are replaced on other nodes. A replica with a volume waits for its node instead. See when a node goes away.

Things to know

  • port is only for inbound HTTP. Set it if a service routes here. unisrv up rejects a port that nothing routes to.
  • replicas = 0 keeps the deployment defined but runs nothing.
  • Moving tags aren't re-pulled. Re-pushing :latest does nothing until instances are replaced. Click Invalidate on the deployment or run unisrv up --invalidate. Immutable tags avoid the problem.
  • The container filesystem is scratch. Anything outside a volume is gone when the instance is replaced.

CLI HCL reference: deployment.

On this page