Skip to content

Commit 6c08019

Browse files
[Docs]: Service rolling deployments (#2870)
Co-authored-by: peterschmidt85 <andrey.cheptsov@gmail.com>
1 parent 3d3dfd0 commit 6c08019

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

docs/docs/concepts/services.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,61 @@ utilization_policy:
679679
[`max_price`](../reference/dstack.yml/service.md#max_price), and
680680
among [others](../reference/dstack.yml/service.md).
681681

682+
## Rolling deployment
683+
684+
To deploy a new version of a service that is already `running`, use `dstack apply`. `dstack` will automatically detect changes and suggest a rolling deployment update.
685+
686+
<div class="termy">
687+
688+
```shell
689+
$ dstack apply -f my-service.dstack.yml
690+
691+
Active run my-service already exists. Detected changes that can be updated in-place:
692+
- Repo state (branch, commit, or other)
693+
- File archives
694+
- Configuration properties:
695+
- env
696+
- files
697+
698+
Update the run? [y/n]:
699+
```
700+
701+
</div>
702+
703+
If approved, `dstack` gradually updates the service replicas. To update a replica, `dstack` starts a new replica, waits for it to become `running`, then terminates the old replica. This process is repeated for each replica, one at a time.
704+
705+
You can track the progress of rolling deployment in both `dstack apply` or `dstack ps`.
706+
Older replicas have lower `deployment` numbers; newer ones have higher.
707+
708+
<!--
709+
Not using termy for this example, since the example shows an intermediate CLI state,
710+
not a completed command.
711+
-->
712+
713+
```shell
714+
$ dstack apply -f my-service.dstack.yml
715+
716+
⠋ Launching my-service...
717+
NAME BACKEND PRICE STATUS SUBMITTED
718+
my-service deployment=1 running 11 mins ago
719+
replica=0 job=0 deployment=0 aws (us-west-2) $0.0026 terminating 11 mins ago
720+
replica=1 job=0 deployment=1 aws (us-west-2) $0.0026 running 1 min ago
721+
```
722+
723+
The rolling deployment stops when all replicas are updated or when a new deployment is submitted.
724+
725+
??? info "Supported properties"
726+
<!-- NOTE: should be in sync with constants in server/services/runs.py -->
727+
728+
Rolling deployment supports changes to the following properties: `resources`, `volumes`, `docker`, `files`, `image`, `user`, `privileged`, `entrypoint`, `working_dir`, `python`, `nvcc`, `single_branch`, `env`, `shell`, `commands`, as well as changes to [repo](repos.md) or [file](#files) contents.
729+
730+
Changes to `replicas` and `scaling` can be applied without redeploying replicas.
731+
732+
Changes to other properties require a full service restart.
733+
734+
To trigger a rolling deployment when no properties have changed (e.g., after updating [secrets](secrets.md) or to restart all replicas),
735+
make a minor config change, such as adding a dummy [environment variable](#environment-variables).
736+
682737
--8<-- "docs/concepts/snippets/manage-runs.ext"
683738

684739
!!! info "What's next?"

src/dstack/_internal/server/services/runs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ def _validate_run_spec_and_set_defaults(run_spec: RunSpec):
944944
"replicas",
945945
"scaling",
946946
# rolling deployment
947+
# NOTE: keep this list in sync with the "Rolling deployment" section in services.md
947948
"resources",
948949
"volumes",
949950
"docker",

0 commit comments

Comments
 (0)