A local volume mounts a local storage device to a pod, such as a disk, partition, or directory. This topic describes how to use local volumes.

Background information

For more information about the solution provided by Container Service for Kubernetes (ACK) to mount local volumes, see local.

The following table compares local volumes and hostPath volumes.
HostPath LocalVolume
Does not support pod scheduling policies. Supports pod scheduling policies.
Allows you to mount directories and files to pods. Allows you to mount directories or storage devices to pods.
Supports the feature of automatically creating directories in host nodes. Does not support the feature of automatically creating directories in host nodes.

Use local volumes

Use the following template to provision a local volume as a persistent volume (PV):
apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-pv
spec:
  capacity:
    storage: 100Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    path: /mnt/disks/ssd1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - example-node

local volumes can be only statically provisioned as PVs. Dynamic provisioning is not supported. The Kubernetes community provides a solution to dynamically provision local volumes as PVs. For more information, see sig-storage-local-static-provisioner.