Key idea
A manifest, computesphere.yaml, describes your services in a file. It lives in your repository, gets reviewed like code, and csph turns it into running services, the same way every time.
One file, applied the same way every time
In your repository, reviewed like code.
csph applycomputesphere/deploy@v1 Project Access token, csph_…staging
prod
Every run reportscreatedupdatedunchanged
YAML in five lines
key: valuesets one field.- Indenting by two spaces puts fields inside the one above.
- A line starting with
-is one item in a list. #starts a comment.- Quote values that could be misread, like
"2".
Step 1: one service
Every csph deploy --image builds a one-service manifest behind the scenes. Add --write and csph also saves it to the current directory:
csph deploy --image quay.io/computesphere/learn-hello-web:1.0.0 --name hello-web --port 8080 --write
version: "2"
services:
- name: hello-web
type: web-service
image: quay.io/computesphere/learn-hello-web:1.0.0
port: 8080
That's complete: a version and a list of services. Each service needs a name and a type, plus what that type requires. A web service without port is rejected before anything is created.
Step 2: project, environments and a second service
Here's the shop from Module 2, deployed into staging and prod:
version: "2"
project:
name: shop
environments:
- name: staging
region: us-east-1 # a name from `csph regions list`
secrets:
API_KEY:
secret: true
overrides:
services:
web:
spherelets: 1
- name: prod
region: us-east-1
secrets:
API_KEY:
secret: true
services:
- name: web
type: web-service
image: quay.io/computesphere/learn-sample-api:1.0.0
port: 8080
plan: FLX # the spherelet shape: FLX, MAX or PWR
spherelets: 2
health_check_path: /hello
env_vars:
GREETING: Hello from the manifest
- name: emails
type: background-worker
image: ghcr.io/acme/shop-emails:1.4.0
env_vars:
SHOP_URL:
fromService: web
property: url
What each new part does:
projectandenvironments: on apply, each environment is found by name, or created if missing.regionis only used when creating one.servicesare deployed into every listed environment, so staging and prod each get their ownwebandemails.planis the spherelet shape:FLX(Flex),MAX(Standard) orPWR(Performance). Set it on every service; without it the service is created with no shape.overrideschanges a service in one environment:webruns 2 spherelets, except 1 in staging.fromService: web,property: urlfills in web's public URL on apply, so nobody copies it by hand.
Leave out project and environments and you choose where services go when you apply (next lesson).
Service fields and environment variables
| Field | Used by | Sets |
|---|---|---|
name, type | all | Unique name; web-service, background-worker, cron-job or static-site |
image | web service, worker, cron job | The image to run |
port | web service | Required |
spherelets | web service, worker | 1 if left out |
health_check_path | web service | The health check's Endpoint path |
schedule, command | cron job | Both required |
env_vars | all | Variables for this service |
An environment can also have a variables block that every service shares; a service's own env_vars win on the same name. An environments list always needs a project block.
Secrets stay out of the file
Anything in Git should be treated as public, so secret values never go in the manifest. An environment's secrets block only declares the name with secret: true. Set the value in the console (lesson 5.4.1), where it's safest. Re-applying never overwrites it.
Check yourself
What stays out of the manifest
Volumes aren't in the file yet. Attach them in the console or with csph, and note them in your README.