Provision with LocalVolume

A LocalVolume statically provisions one PersistentVolume per listed device path. The operator also creates the StorageClass named in spec.storageClassDevices[].storageClassName if it does not exist.

Use LocalVolume when you know the exact disks. For filter-based provisioning, see Provision with LocalVolumeSet.

Prerequisites

  • Alauda Container Platform Local Disk Provisioner is installed. See Install.
  • Each target device is attached to a node, is not mounted, and has no partitions.
  • Prefer stable paths from Discover local disks, such as /dev/disk/by-id/.... Do not use a short /dev/sdX name or a /dev/disk/by-path/... path. Those names can change after a node reboot.

Provision Filesystem volumes

Local volumes are static. The provisioner looks for devices at the paths you list.

NOTE

Do not use different StorageClass names for the same device. That creates multiple PersistentVolumes for one disk.

On a control plane node:

cat << EOF | kubectl apply -f -
apiVersion: local.storage.openshift.io/v1
kind: LocalVolume
metadata:
  name: local-disks
  namespace: acp-storage
spec:
  nodeSelector:
    nodeSelectorTerms:
      - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
              - worker-01
              - worker-02
              - worker-03
  storageClassDevices:
    - storageClassName: local-sc
      forceWipeDevicesAndDestroyAllData: false
      volumeMode: Filesystem
      fsType: xfs
      devicePaths:
        - /dev/disk/by-id/<wwn-id>
EOF
  1. Namespace where Alauda Container Platform Local Disk Provisioner is installed. The default is acp-storage.
  2. Optional. Nodes that have the listed disks. Get hostnames from kubectl get node. If omitted, the operator looks for the paths on every node.
  3. StorageClass for the PersistentVolumes. The operator creates it if it does not exist. Use a name that uniquely identifies this set of disks.
  4. When true, the operator wipes partition tables, filesystem signatures, and data on the listed devices before use. The default is false. Set true only when the devices can be destroyed.
  5. Filesystem or Block.
  6. Filesystem created on first mount. Set this only when volumeMode is Filesystem.
  7. Device paths. Use /dev/disk/by-id/... from LocalVolumeDiscoveryResult.status.discoveredDevices[].deviceID. Do not use /dev/sdX or /dev/disk/by-path/....
WARNING

forceWipeDevicesAndDestroyAllData: true destroys existing data on the listed devices.

Verify PersistentVolumes:

kubectl get pv

Example output:

NAME                CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
local-pv-n8xlrd2a   100Gi      RWO            Delete           Available           local-sc                88m
local-pv-tc78vc73   100Gi      RWO            Delete           Available           local-sc                82m
NOTE

Editing a LocalVolume does not change fsType or volumeMode on PersistentVolumes that already exist. That change would be destructive.

Provision Block volumes

To provision raw block devices, set volumeMode: Block and omit fsType:

      volumeMode: Block
      devicePaths:
        - /dev/disk/by-id/<wwn-id>

Use a StorageClass name that identifies this Block set, for example localblock. The PersistentVolumeClaim must also set volumeMode: Block.

Bind a PersistentVolumeClaim

Create the claim in the project that will use the volume. The request must not exceed the device capacity.

Filesystem claim:

cat << EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: local-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 100Gi
  storageClassName: local-sc
EOF
  1. Must match the LocalVolume volumeMode. Use Block for Block volumes.
  2. Must be less than or equal to the PersistentVolume capacity.
  3. Must match spec.storageClassDevices[].storageClassName.

Confirm the claim is bound:

kubectl get pvc local-pvc

Add disks or nodes

Adding a disk or a node is an edit of the same LocalVolume. It is not a separate procedure.

  • Add a disk: append a /dev/disk/by-id/... path to spec.storageClassDevices[].devicePaths.
  • Add a node: add the node hostname to spec.nodeSelector.nodeSelectorTerms, then list that node's device paths.

After you apply the edit, wait for new PersistentVolumes in Available state:

kubectl get pv -l storage.openshift.com/owner-name=local-disks