Skip to main content

Storage

Available

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 in user.

Steps​

1. Declare the volume​

db.yml
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​

PointBehavior
Accessa single instance of the service at a time
replicas0 or 1 only; sng app scale db 2 is refused
autoscaleforbidden
strategyalways recreate: the service is stopped before being restarted (downtime during the restart)
Sizesize: 10Gi; growing a volume afterwards is not documented in this version
Number10 volumes at most per service, absolute path of 256 characters at most
Identitya volume is identified by its path; reordering the list does not swap the data, changing the path creates a new empty volume
Deleting the Appthe App's services disappear, the volumes remain with their data
Deleting the servicesame: the service's volumes are kept
Disk typeset by the platform, cannot be chosen
A volume is not a share

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 seeCauseFix
Manifest rejected with replicas, autoscale or strategy: rollingA service with a volume runs as a single instanceRemove these fields
sng app scale db 2 refusedSameKeep 1, or remove the volume
The service starts but cannot write to the volumeThe image runs under a uid other than userSet in user the image's uid (999 for postgres)
The data disappeared after a manifest changeThe volume path changed: it is a new volumePut 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.

See also​