Skip to content

OpenEBS: container-attached storage on Kubernetes with cStor, Mayastor, and LocalPV

Install OpenEBS on Kubernetes, choose between LocalPV, cStor, and Mayastor engines, and apply the configuration we use for replicated and local-only persistent volumes.

OpenEBS is a CNCF-incubating storage stack for Kubernetes that gives you multiple storage engines under one operator umbrella — LocalPV for fast local volumes without replication, cStor for ZFS-backed replicated storage, and Mayastor for NVMe-over-fabrics performance. The right engine depends on the workload: stateful apps that handle their own replication (Postgres with streaming replicas, Cassandra) want LocalPV speed; apps without internal redundancy (single-node Redis, MongoDB) want cStor or Mayastor replication. This article walks the install via Helm and the engine-specific configuration we apply to the customer clusters we manage.

How to verify

# Operator namespace and pods
kubectl get pods -n openebs

# Available storage classes
kubectl get storageclass

# Engine-specific resources
kubectl get cstorpoolclusters -A   # cStor
kubectl get diskpool -A             # Mayastor
kubectl get blockdevices -A         # LocalPV-Device
kubectl get sc | grep openebs

What’s happening

The OpenEBS project has consolidated around three distinct engines, each with a different architecture. LocalPV is the simplest: it creates a PV on a local disk or filesystem path on the node where the pod is scheduled. There’s no replication and no network hop, so it’s fast but loses data if the node dies. Variants include LocalPV-hostpath (a directory on the node), LocalPV-LVM (LVM logical volume), LocalPV-ZFS (ZFS dataset), and LocalPV-Device (raw block device). For workloads with app-level replication, LocalPV is often the best fit.

cStor is a ZFS-derived replicated engine. It creates a “cStor pool” on each storage node, layered on top of ZFS volumes, and replicates writes to multiple pool instances across nodes. Snapshots and clones are first-class, and the data integrity guarantees from ZFS (checksum-on-read, scrub) come along for free. cStor is heavyweight — it’s a full storage controller running in containers — but it’s mature and the replication semantics are predictable.

Mayastor is the new(er) engine optimized for NVMe over fabrics. It uses SPDK (Storage Performance Development Kit) for userspace I/O, presenting volumes as NVMe-oF targets. Performance is significantly better than cStor for NVMe-class workloads — close to bare-metal NVMe speeds with replication. The tradeoff is that Mayastor requires hugepages, NVMe-capable kernel modules, and more careful node prep. We use it for high-performance databases and ML pipelines; not for every workload.

The decision matrix is roughly: app does its own replication → LocalPV; app needs replicated storage with broad compatibility → cStor; high-performance NVMe workload → Mayastor. Mixing engines in one cluster is supported and common.

The procedure

  1. Install the OpenEBS Helm chart:

    helm repo add openebs https://openebs.github.io/charts
    helm repo update
    kubectl create namespace openebs
    helm install openebs openebs/openebs \
      --namespace openebs \
      --set engines.local.lvm.enabled=true \
      --set engines.local.zfs.enabled=true \
      --set engines.replicated.mayastor.enabled=true \
      --version 4.1.0
  2. Verify pods come up:

    kubectl -n openebs get pods
    kubectl -n openebs get sc
  3. LocalPV-hostpath — the lightest option. Create a storage class with a node directory:

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: openebs-hostpath-fast
    provisioner: openebs.io/local
    reclaimPolicy: Delete
    volumeBindingMode: WaitForFirstConsumer
    parameters:
      StorageType: hostpath
      BasePath: /var/openebs/local
  4. LocalPV-LVM — if nodes have an LVM volume group called vg-data:

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: openebs-lvm-ext4
    provisioner: local.csi.openebs.io
    parameters:
      vgpattern: "^vg-data$"
      fsType: "ext4"
  5. Mayastor — node prep first. On every node that will host Mayastor disk pools:

    # Enable hugepages (2GB worth at 2MB page size = 1024 pages)
    echo 1024 | sudo tee /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
    echo "vm.nr_hugepages=1024" | sudo tee -a /etc/sysctl.conf
    # Load NVMe kernel modules
    sudo modprobe nvme_tcp
    echo nvme_tcp | sudo tee /etc/modules-load.d/nvme.conf
    # Label nodes that participate
    kubectl label node worker-1 openebs.io/engine=mayastor

    Then create a DiskPool CR per node:

    apiVersion: openebs.io/v1beta2
    kind: DiskPool
    metadata:
      name: pool-worker-1
      namespace: openebs
    spec:
      node: worker-1
      disks:
        - /dev/nvme1n1

    And a Mayastor storage class:

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: mayastor-3replicas
    provisioner: io.openebs.csi-mayastor
    allowVolumeExpansion: true
    parameters:
      repl: "3"
      protocol: nvmf
      fsType: ext4
  6. Test with a sample PVC + Pod and verify the volume mounts on the right node and the engine-specific resources show up:

    kubectl get pvc
    kubectl get pv
    kubectl get mayastorvolumes -n openebs   # for Mayastor

Common pitfalls

  • LocalPV pods can’t be rescheduled to a different node — the PV is tied to a specific node’s disk. If the node dies, the PV is gone. Plan with affinity rules.
  • Mayastor hugepage requirement is per-node and must persist across reboots; otherwise after a kernel update Mayastor pods crash-loop.
  • cStor recovery after multi-node failure is complex — get familiar with the cStor pool restore procedure before the cluster goes live.
  • StorageClass volumeBindingMode: Immediate causes provisioning before the pod is scheduled, which doesn’t work for LocalPV; always use WaitForFirstConsumer for local engines.
  • Mixing engines requires named storage classes — accidentally using the default class can land your “I need fast local” PVC on Mayastor instead.

In the engagements we run, OpenEBS is the choice when the customer’s workload mix needs different storage characteristics on the same cluster — a single Helm install gives us LocalPV for replicated databases, Mayastor for high-IOPS workloads, and the ability to mix without standing up multiple operators. We document the per-class semantics in the customer runbook, alert on engine-specific health (mayastor volumes, cStor pool state), and stage more capable replicated stacks only when the workload pattern justifies the operational overhead.