You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/concepts/services.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -681,6 +681,52 @@ utilization_policy:
681
681
682
682
--8<-- "docs/concepts/snippets/manage-runs.ext"
683
683
684
+
## Deployments
685
+
686
+
To deploy a new version of the service, change its configuration or associated resources, such as files or repo contents. Then, re-run `dstack apply`.
687
+
688
+
<div class="termy">
689
+
690
+
```shell
691
+
$ dstack apply -f my-service.dstack.yml
692
+
693
+
Active run my-service already exists. Detected changes that can be updated in-place:
694
+
- Repo state (branch, commit, or other)
695
+
- File archives
696
+
- Configuration properties:
697
+
- env
698
+
- files
699
+
700
+
Update the run? [y/n]:
701
+
```
702
+
703
+
</div>
704
+
705
+
If `dstack` can apply all the detected changes without a full service restart, it starts a rolling deployment. During the rolling deployment, `dstack` gradually updates the service replicas to the new version. First, it starts an extra replica. Then, it waits until this replica enters the `running` state. Finally, it terminates the old replica.
706
+
707
+
During deployment, new and old replicas can coexist and handle requests simultaneously. If the service has multiple replicas, they are updated one by one — there can be at most one extra replica above the desired number of replicas, as determined by the `replicas` and `scaling` properties.
708
+
709
+
You can track the deployment progress in the `dstack apply` output. The `deployment` number will be lower for old replicas and higher for new ones.
710
+
711
+
```shell
712
+
$ dstack apply -f my-service.dstack.yml
713
+
714
+
⠋ Launching my-service...
715
+
NAME BACKEND PRICE STATUS SUBMITTED
716
+
my-service deployment=1 running 11 mins ago
717
+
replica=0 job=0 deployment=0 aws (us-west-2) $0.0026 terminating 11 mins ago
718
+
replica=1 job=0 deployment=1 aws (us-west-2) $0.0026 running 1 min ago
719
+
```
720
+
721
+
A deployment stops either when all of the replicas are up to date or when the next deployment is submitted.
722
+
723
+
<!-- NOTE: should be in sync with constants in server/services/runs.py -->
724
+
725
+
Rolling deployments apply to the following configuration properties: `resources`, `volumes`, `docker`, `files`, `image`, `user`, `privileged`, `entrypoint`, `working_dir`, `python`, `nvcc`, `single_branch`, `env`, `shell`, `commands`. They also apply to changes to [repo](repos.md) or [file](#files) contents.
726
+
727
+
??? info "Forcing a redeployment"
728
+
Sometimes you may want to run a rolling deployment even if `dstack` detects no changes to the configuration or associated resources. This can be useful if you've changed the project [secrets](secrets.md) or if you just want to gradually restart all service replicas. Currently, this can be achieved by making an insignificant change to the configuration, such as adding a dummy [environment variable](#environment-variables).
729
+
684
730
!!! info "What's next?"
685
731
1. Read about [dev environments](dev-environments.md), [tasks](tasks.md), and [repos](repos.md)
0 commit comments