infraops

💾 Application storage

← Back to README · Application deployment

An application can declare multiple persistent volumes in its storage map. Each entry specifies the volume name, capacity, and mount path.

storage: {
  data: {
    capacity: 1Gi
    path: /data
  }
  archive: {
    capacity: 2Gi
    path: /staging
  }
}

The apps program uses the cluster’s do-block-storage-retain StorageClass. Set capacity explicitly. Kubernetes validates the quantity and storage availability. Each claim requests ReadWriteOnce and Filesystem. Pulumi waits for the claims before rolling out the Deployment. All replicas share the same claims. ReadWriteOnce permits multiple pods on one node, so configure replicas and rollout strategy to suit the application’s concurrency requirements. See the Storage schema.

Each claim mounts writable at its own absolute, clean, non-root path. Choose a directory that leaves image files, /etc/<app>, and /etc/secrets accessible. Configure the service to put persistent data and any required writable workspace under the mount. Containers use a read-only root filesystem, UID/GID 10001, and fsGroup: 2000. Verify that the driver supports group access and that the application can write to the mount and recover after pod replacement. See the Kubernetes security context guidance.

🔄 Change or migrate a claim

The Kubernetes and Pulumi claim name is <app>-<volume> in the app’s namespace. Volume keys use lowercase ASCII letters and digits. The combined name must be a DNS label of at most 63 characters. Pod replacement, config changes, image changes, and scaling preserve the claim’s identity.

To carry an existing <app>-data claim on do-block-storage-retain into named storage, put its existing capacity and path under data. For a claim with a different or unset class, migrate data to the retained class before applying the new configuration. When migrating from the old schema, pause automated version bumps until every app pipeline uses a release image with cmd/bump built for named storage. Older helpers can drop named volumes while bumping any app in apps.hjson.

Renaming a volume or app or moving it to another namespace changes the claim identity and requires an explicit data migration. Changing the mount path keeps the claim and requires updating the service configuration. Expansion requires StorageClass and driver support. Plan a migration if you need a smaller disk.

[!CAUTION] Claims use Pulumi protection. Back up or migrate data and review the preview before unprotecting a claim for replacement or removal. Rolling back to code or configuration without storage can attempt to remove the claim.

Kubernetes can still delete claims directly, including during namespace or cluster deletion. The Retain policy keeps the backing disk available and billable after claim deletion. See the Kubernetes reclaim policy guidance.

🗑️ Delete a retained disk

  1. Find the bound PV with kubectl get pv and record its name and DigitalOcean volume ID (spec.csi.volumeHandle) before removing the claim.
  2. Stop or migrate the workload using the disk. For a Pulumi-managed claim, unprotect it, remove its storage configuration, then preview and apply the apps update. Wait for DigitalOcean to show the disk as detached.
  3. In DigitalOcean Volumes, locate the disk you recorded, then choose More → Delete → Confirm. This permanently deletes the data and stops billing for the disk. See the DigitalOcean deletion instructions.
  4. Delete the corresponding Released PV from Kubernetes.