Persistent Storage Using Local Volume

Overview

OKD clusters can be provisioned with persistent storage by using local volumes. Local persistent volume allows you to access local storage devices such as a disk, partition or directory by using the standard PVC interface.

Local volumes can be used without manually scheduling pods to nodes, because the system is aware of the volume’s node constraints. However, local volumes are still subject to the availability of the underlying node and are not suitable for all applications.

Local volumes is an alpha feature and may change in a future release of OKD. See Feature Status(Local Volume) section for details on known issues and workarounds.

Local volumes can only be used as a statically created Persistent Volume.

Provisioning

Storage must exist in the underlying infrastructure before it can be mounted as a volume in OKD. Ensure that OKD is configured for Local Volumes, before using the PersistentVolume API.

Creating Local Persistent Volume

Define the persistent volume in an object definition.

  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4. name: example-local-pv
  5. spec:
  6. capacity:
  7. storage: 5Gi
  8. accessModes:
  9. - ReadWriteOnce
  10. persistentVolumeReclaimPolicy: Delete
  11. storageClassName: local-storage
  12. local:
  13. path: /mnt/disks/ssd1
  14. nodeAffinity:
  15. required:
  16. nodeSelectorTerms:
  17. - matchExpressions:
  18. - key: kubernetes.io/hostname
  19. operator: In
  20. values:
  21. - my-node

Creating Local Persistent Volume Claim

Define the persistent volume claim in an object definition.

  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. name: example-local-claim
  5. spec:
  6. accessModes:
  7. - ReadWriteOnce
  8. resources:
  9. requests:
  10. storage: 5Gi (1)
  11. storageClassName: local-storage (2)
1The required size of storage volume.
2The name of storage class, which is used for local PVs.

Feature Status

What Works:

  • Creating a PV by specifying a directory with node affinity.

  • A Pod using the PVC that is bound to the previously mentioned PV always get scheduled to that node.

  • External static provisioner daemonset that discovers local directories, creates, cleans up and deletes PVs.

What does not work:

  • Multiple local PVCs in a single pod.

  • PVC binding does not consider pod scheduling requirements and may make sub-optimal or incorrect decisions.

    • Workarounds:

      • Run those pods first, which requires local volume.

      • Give the pods high priority.

      • Run a workaround controller that unbinds PVCs for pods that are stuck pending.

  • If mounts are added after the external provisioner is started, then external provisioner cannot detect the correct capcity of mounts.

    • Workarounds:

      • Before adding any new mount points, first stop the daemonset, add the new mount points, and then start the daemonset.
  • fsgroup conflict occurs if multiple pods using the same PVC specify different fsgroup ‘s.