User Tools

Site Tools


zededa:sharing-persist-volume-by-two-apps

This is an old revision of the document!


Sharing a Persistent Volume Between Multiple Apps (ZEDEDA / EVE-OS)

Can a persistent volume be shared by two applications?

Yes. ZEDEDA/EVE-OS supports attaching a single volume instance to multiple application instances via the multiattach flag combined with the MULTIREAD_SINGLEWRITE access mode. Sharing data between edge apps on the same node is one of the documented primary use cases of the storage feature.

This is a supported, real-world pattern — it is exactly what ZEDEDA's own example_fcm_app_deployment.py SDK example does: one content-tree volume + block-storage volumes with multiattach=True shared across 7 app instances on one node.

Access modes

The accessmode field accepts these enum values:

Value Meaning
VOLUME_INSTANCE_ACCESS_MODE_READWRITE Single app, read-write (default for a private volume)
VOLUME_INSTANCE_ACCESS_MODE_READONLY Read-only
VOLUME_INSTANCE_ACCESS_MODE_MULTIREAD_SINGLEWRITE Shared: many readers, one writer
VOLUME_INSTANCE_ACCESS_MODE_INVALID Unset / invalid

To share, use MULTIREAD_SINGLEWRITE and set multiattach = true.

Important constraints

  • Same node only. A persistent volume instance belongs to a specific edge node. To share it, every app instance attaching it must run on that same edge node. To have it on another node you must create a separate volume instance there.
  • One writer, many readers. MULTIREAD_SINGLEWRITE means the platform lets multiple apps attach, but it does not arbitrate concurrent writers. Two apps mounting the same block device read-write and both writing will corrupt the filesystem (ext4/xfs are not cluster-aware).
  • Safe pattern: one app owns writes; the others mount read-only (readonly = true on the drive). If you genuinely need concurrent read-write from multiple apps, do not use block-level multiattach — instead have one app export the data over a network share (NFS / SMB / MinIO) that the others mount.

Terraform (zedcloud provider)

The zedcloud_volume_instance resource exposes both accessmode and multiattach, so this is done entirely in Terraform.

Volume definition

resource "zedcloud_volume_instance" "shared_persist" {
  device_id   = zedcloud_edgenode.my_edgenode.id
  accessmode  = "VOLUME_INSTANCE_ACCESS_MODE_MULTIREAD_SINGLEWRITE"
  multiattach = true
  cleartext   = false
  label       = "shared-persist"
  name        = "shared-persist"
  size_bytes  = 1073741824
  title       = "shared-persist"
  type        = "VOLUME_INSTANCE_TYPE_BLOCKSTORAGE"
  lifecycle {
    ignore_changes = [device_id]
  }
}

Attaching to the writer app (read-write)

  drives {
    imagename   = ""
    volumelabel = zedcloud_volume_instance.shared_persist.label
    mountpath   = "/data"
    cleartext   = false
    ignorepurge = true
    maxsize     = 1073741824
    preserve    = true
    target      = "Disk"
    drvtype     = "HDD"
    readonly    = false   ### writer
  }

Attaching to the reader app(s) (read-only)

  drives {
    imagename   = ""
    volumelabel = zedcloud_volume_instance.shared_persist.label
    mountpath   = "/data"
    cleartext   = false
    ignorepurge = true
    maxsize     = 1073741824
    preserve    = true
    target      = "Disk"
    drvtype     = "HDD"
    readonly    = true    ### reader
  }

Common mistake

Referencing the same volume from two app instances while the volume is still defined as plain VOLUME_INSTANCE_ACCESS_MODE_READWRITE with no multiattach is not a valid shared config — it either fails to attach to the second app or produces two uncoordinated read-write mounts. Always set multiattach = true + MULTIREAD_SINGLEWRITE, and keep only one writer.

Summary

  • Sharing a persistent volume across apps is supported — multiattach = true + MULTIREAD_SINGLEWRITE.
  • Same edge node for all attaching apps.
  • One writer, others read-only; for concurrent multi-writer, use a network share instead.
  • Fully configurable in the zedcloud Terraform provider (accessmode, multiattach, per-drive readonly).
zededa/sharing-persist-volume-by-two-apps.1784663202.txt.gz · Last modified: by mc