Storage
Deployed and supported. The fields and commands described here are stable within version v1alpha1.
A service can mount one or more persistent volumes: the data survives restarts, updates and even deletion of the App. In return, a service with a volume runs as a single instance.
Prerequisites
- An App being written (From docker compose).
- An image that writes to a known path (
/var/lib/postgresql/data,/data…) and runs under a non-administrator uid: the volume belongs to the uid given inuser.
Steps
1. Declare the volume
apiVersion: deploy.stackngo.io/v1alpha1
kind: App
metadata:
name: db
spec:
services:
postgres:
image: postgres:17
user: "999" # postgres uid: the volume belongs to it
ports: ["5432"]
env:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_PASSWORD: { secret: db, key: password }
healthcheck: { cmd: ["pg_isready", "-U", "postgres"] }
volumes:
- { path: /var/lib/postgresql/data, size: 10Gi }
No replicas, no autoscale, no strategy (or strategy: { type: recreate }):
otherwise the schema rejects the manifest.
2. Apply
sng apply db.yml
sng app describe db
App : db
Statut : prête
SERVICE KIND IMAGE PHASE URL DETAIL
postgres deployment postgres:17 Ready - Reconciled 1/1 prêts
Verification
Write to the database, then sng app restart db: the data is still there after the
restart. sng app patch db --image postgres:17.2 does the same: the service is stopped,
then restarted on the same volume.
What you need to know
| Point | Behavior |
|---|---|
| Access | a single instance of the service at a time |
replicas | 0 or 1 only; sng app scale db 2 is refused |
autoscale | forbidden |
strategy | always recreate: the service is stopped before being restarted (downtime during the restart) |
| Size | size: 10Gi; growing a volume afterwards is not documented in this version |
| Number | 10 volumes at most per service, absolute path of 256 characters at most |
| Identity | a volume is identified by its path; reordering the list does not swap the data, changing the path creates a new empty volume |
| Deleting the App | the App's services disappear, the volumes remain with their data |
| Deleting the service | same: the service's volumes are kept |
| Disk type | set by the platform, cannot be chosen |
Two services cannot mount the same volume, and a service with a volume cannot be replicated. For shared files or files served in bulk, use object storage or the CDN.
Delete the data
sng app delete db keeps the volume. In this version, there is no field or
command to delete it yourself: ask support, giving the name of the App and the
service. If you recreate an App with the same name and the same path, it finds the volume
and its data again.
If it doesn't work
| What you see | Cause | Fix |
|---|---|---|
Manifest rejected with replicas, autoscale or strategy: rolling | A service with a volume runs as a single instance | Remove these fields |
sng app scale db 2 refused | Same | Keep 1, or remove the volume |
| The service starts but cannot write to the volume | The image runs under a uid other than user | Set in user the image's uid (999 for postgres) |
| The data disappeared after a manifest change | The volume path changed: it is a new volume | Put the old path back: the old volume is found again |
Going further
- Named compose volumes become 1Gi volumes on translation: remember to adjust
size(From docker compose). - The size of a volume counts toward the quota of your plan; see Tiers.