Using block devices in Kubernetes

2 min read · Beginner


Edera supports native Kubernetes storage APIs. You can mount block devices directly into pods using standard PersistentVolumes—no special configuration required.

This means you can use local NVMe drives, CSI-managed volumes, or raw host block devices with Edera workloads the same way you would without Edera.

How it works

  1. Create a PersistentVolume pointing to your block device
  2. Create a PersistentVolumeClaim to request the storage
  3. Mount it in your pod with runtimeClassName: edera

Example: Local NVMe device

This example mounts a local NVMe device (/dev/nvme01) into an Edera-protected workload.

PersistentVolume

kind: PersistentVolume
apiVersion: v1
metadata:
  name: local-raw-pv-rw
spec:
  volumeMode: Block
  capacity:
    storage: 5Gi
  local:
    path: /dev/nvme01
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
                - my-host

PersistentVolumeClaim

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: block-pvc-rw
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Block
  resources:
    requests:
      storage: 2Gi

Workload

apiVersion: batch/v1
kind: Job
metadata:
  name: host-blockdev-rw-pv
spec:
  backoffLimit: 0
  template:
    spec:
      runtimeClassName: edera
      nodeSelector:
        kubernetes.io/hostname: my-host
      containers:
        - name: test
          image: alpine:latest
          command: ["/bin/sh", "-c"]
          args:
            - |
              echo "=== Blockdev Test ==="
              echo ""
              echo "1. Blockdev at /mnt/high-perf-dev:"
              if echo "test" > /mnt/high-perf-dev/test && [ -f /mnt/high-perf-dev/test ]; then
                  echo "   SUCCESS: Blockdev writable"
              else
                  echo "   FAILURE: Blockdev not present/writable"
                  exit 1
              fi              
          volumeDevices:
            - name: data
              devicePath: /mnt/high-perf-dev
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: block-pvc-rw
      restartPolicy: Never

The key elements:

  • runtimeClassName: edera - Runs the workload in an isolated Edera zone
  • volumeMode: Block - Uses raw block device access
  • volumeDevices - Mounts the block device at the specified path

Additional notes

Native Kubernetes storage APIs (PersistentVolumes and block devices) are supported starting in Edera v1.6.0

Non-Kubernetes use cases

If you’re running Edera outside of Kubernetes, see:

Further reading

Last updated on