All Products
Search
Document Center

Container Service for Kubernetes:Use LVM to dynamically create local volumes

Last Updated:Jun 17, 2026

Provision and manage local volumes as PVs and PVCs on ACK Edge Pro cluster nodes with LVM. Pods are scheduled to nodes based on available LVM storage capacity.

Prerequisites

  • Local disks are available on cluster nodes.

  • TCP port 1736 on the storage node is accessible from the cloud node.

Step 1: Install the node-resource-manager, csi-plugin, and csi-provisioner add-ons

These add-ons provide Container Storage Interface (CSI) support for local LVM volumes. Install all three before using LVM to manage local storage.

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the target cluster name and choose Operations > Add-ons in the left-side navigation pane.

  3. On the Add-ons page, click the Storage tab. Find node-resource-manager, csi-plugin, and csi-provisioner, and click Install.

  4. In the dialog box, click OK.

Step 2: Configure the VolumeGroup

A VolumeGroup specifies which local disks LVM manages on a node. Create a ConfigMap to map node labels to disk topologies. The VolumeGroup in prose corresponds to the volumegroup field in the ConfigMap YAML.

Note

For data security, the add-ons do not delete VolumeGroups or physical volumes (LVM physical volumes, distinct from Kubernetes PersistentVolumes). Delete an existing VolumeGroup before redefining it.

  1. Configure the VolumeGroup topology with the following ConfigMap:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: node-resource-topo
      namespace: kube-system
    data:
      volumegroup: |-
        volumegroup:
        - name: volumegroup1
          key: kubernetes.io/storagetype
          operator: In
          value: lvm
          topology:
            type: device
            devices:
            - /dev/sdb1
            - /dev/sdb2
            - /dev/sdc

    The following table describes the parameters.

    Parameter

    Description

    name

    The name of the VolumeGroup.

    key

    The label key to match on nodes.

    operator

    The label selector operator. Valid values: In, NotIn, Exists, DoesNotExist. See the operator values table below.

    value

    The label value to match for the specified key.

    topology

    The device topology on the node. topology.devices lists the local disk paths to add to the VolumeGroup.

    Operator values

    Value Behavior
    In Matches when the node label value equals the specified value.
    NotIn Matches when the node label value differs from the specified value.
    Exists Matches when the node has a label with the specified key.
    DoesNotExist Matches when the node lacks a label with the specified key.
  2. Add labels to the nodes.

    Add the following labels to storage nodes:

    • Custom topology label: Label storage nodes to match the ConfigMap selector. Example: kubernetes.io/storagetype=lvm.

    • Local storage enablement label: Add alibabacloud.com/edge-enable-localstorage='true' to enable local storage pod scheduling on the node.

    After you add both labels, node-resource-manager automatically creates a physical volume and adds it to the VolumeGroup.

Step 3: Create a PVC and deploy a workload

Define a PVC with the StorageClass in the following YAML and run kubectl apply -f ****.yaml to create it. Each PVC maps to one logical volume on the node, mounted when the pod starts.

Note

In this example, the default storageClassName is csi-local-lvm.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: lvm-pvc-test
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 50Mi
  storageClassName: csi-local-lvm

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: local-test
  name: local-test
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: local-test
  template:
    metadata:
      labels:
        k8s-app: local-test
    spec:
      hostNetwork: true
      containers:
      - image: nginx:1.15.7-alpine
        imagePullPolicy: IfNotPresent
        name: nginx
        resources: {}
        volumeMounts:
          - name: local-pvc
            mountPath: /data
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      tolerations:
      - operator: Exists
      nodeSelector:
        alibabacloud.com/is-edge-worker: "true"
      volumes:
      - name: local-pvc
        persistentVolumeClaim:
          claimName: lvm-pvc-test

Verify the result

Check whether the logical volume is mounted:

kubectl exec -it local-test-564dfcf6dc-qhfsf sh
/ # ls /data

Expected output:

lost+found

This confirms the logical volume is mounted to the pod.