Key idea
csph apply is idempotent: applying the same file twice gives the same result as applying it once. Nothing is created twice and nothing that already matches is touched, so you can run it on every change.
Check the file first
csph apply --file computesphere.yaml --dry-run
✓ manifest is valid — 2 resource(s): [web emails]
A dry run checks the file's shape (required fields, known types, references to real services) and creates nothing. It doesn't compare the file with what's running.
Apply it
csph apply --file computesphere.yaml
For the shop manifest from the last lesson, the first run prints:
Applied 4 resource(s) — status: success
✓ web (web-service) [staging] — created
✓ emails (background-worker) [staging] — created
✓ web (web-service) [prod] — created
✓ emails (background-worker) [prod] — created
Two services in two environments makes four results. A manifest without a project block needs a destination: add --project <project-id> --environment <environment-id>, or set defaults with csph projects use and csph environments use (lesson 5.1.1).
Apply it again
With the file unchanged, every line says unchanged and nothing redeploys. Change web to a new image tag and apply once more: web reports updated in both environments and rolls out, with the old version serving until the new one is healthy. emails stays unchanged.
| Result | Meaning |
|---|---|
created | It didn't exist, so it was made and deployed |
updated | The file changed it, so it was redeployed |
unchanged | It already matches. Nothing happened |
failed | The line below it says why |
Apply only adds
Deleting a service from the file doesn't delete it from ComputeSphere. When you retire a service, delete it on purpose in the console or with csph, and remove it from the file in the same change.
Check yourself
When something fails
The first line's status sums up the run. success exits 0. partial (some failed, the rest kept) and rolled_back (with --atomic, everything this run created was removed) exit 1, so a failed apply fails a CI job.
When a run creates or updates exactly one service, apply waits for it to reach Running and prints its URL. When several change, it returns once they're accepted; follow them with csph deployments list.
Every flag
| Flag | What it does |
|---|---|
--file, -f | The manifest to apply. Required |
--dry-run | Validate only; create nothing |
--atomic | All or nothing: if any resource fails, remove what this run created |
--project, --environment | Where to apply a manifest without its own project |
--no-wait | Don't wait for Running |
--wait-timeout | How long to wait. 5 minutes by default |
--output json | Print the result as JSON |
csph deploy uses the same engine: with no flags it applies the computesphere.yaml in the current directory.