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 Alibaba Cloud Container Service for Kubernetes (ACK) to mount local volumes, see local.

Comparison between local volumes and hostPath volumes
HostPath LocalVolume
Does not support pod scheduling policies. Supports pod scheduling policies.
Allows you to mount directories or 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 about how to dynamically provision and manage local volumes, see sig-storage-local-static-provisioner.