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.

Things to know

  • port is only for inbound HTTP. Set it if a service routes here, omit it for workers.
  • 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.
  • Failures back off, never give up. Repeated crashes stretch the wait between launches up to a cap. A config change resets it.
  • The container filesystem is scratch. Anything outside a volume is gone when the instance is replaced.

CLI HCL reference: deployment.

On this page