ACK Edge Pro cluster nodes support Logical Volume Manager (LVM) local storage with automated logical volume (LV) lifecycle management. Workloads are scheduled based on the LVM storage capacity of each node. Define the local disk topology to consume that storage through native Persistent Volume Claims (PVCs) and Persistent Volumes (PVs) on ACK Edge Pro cluster nodes, as described in this topic.
Prerequisites
-
Local data disks are available on the cluster nodes.
-
TCP port 1736 on the storage node is accessible from the on-cloud node pool.
Install the csi-plugin and csi-provisioner add-ons
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the target cluster name and choose in the left-side navigation pane.
-
On the Storage tab of the Add-ons page, find the csi-plugin and csi-provisioner add-ons, and click Install.
-
In the dialog box, click OK.
Use a ConfigMap to configure the node volume group
To ensure data security, the add-ons do not delete volume groups (VGs) or LVM physical volumes. To redefine a VG, delete the existing one first. Deleting a VG destroys all logical volumes in the VG and the data stored on them, and the deletion cannot be undone. Back up the data or migrate the workloads that use the VG before you delete the VG.
-
Install the node-resource-manager add-on.
-
Use the following sample YAML file to configure a ConfigMap that specifies the VG topology of the node.
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 VG. |
|
key |
Matches the value of the key in the cluster node labels. |
|
operator |
The
|
|
value |
Matches the key label's |
|
topology |
The device topology of the node. |
-
Label the nodes.
-
Add a custom label to each storage node based on the label rule in step 2 to specify the node type that matches the topology. For example, the label in step 2 is
kubernetes.io/storagetype=lvm. -
Add the fixed Alibaba Cloud label
alibabacloud.com/edge-enable-localstorage='true'to each storage node so that the node-resource-manager add-on can be scheduled to the node.
Based on the preceding configuration, the node-resource-manager add-on on the node automatically creates the corresponding LVM physical volume and adds it to the VG.
Manually configure the node volume group
This method creates the VG on the node with LVM commands instead of from the ConfigMap topology. The node-resource-manager add-on and the alibabacloud.com/edge-enable-localstorage='true' label are still required for both methods. Install and configure them as described in the "Use a ConfigMap to configure the node volume group" tab.
-
Connect to the target storage node over Secure Shell (SSH) and check the available local data disks.
lsblk
# Check the unused data disks, such as /dev/sdb1, /dev/sdb2, and /dev/sdc
-
Install the LVM tools if they are not installed.
# CentOS/Anolis
yum install -y lvm2
# Ubuntu/Debian
apt-get install -y lvm2
-
Create the physical volumes and build the VG.
pvcreate /dev/sdb1 /dev/sdb2 /dev/sdc
vgcreate volumegroup1 /dev/sdb1 /dev/sdb2 /dev/sdc
-
The data disk names are examples only. Use the actual names on your node.
-
The VG name must match the
vgNameparameter in the StorageClass. Verify the parameter first:
kubectl get sc csi-local-lvm -o yaml | grep -A5 parameters
If vgName is volumegroup1 (the default value), the VG name in the preceding vgcreate volumegroup1 command already matches this value. If the values differ, adjust the VG name or modify the StorageClass.
Create a PVC and deploy a workload
Use the following sample YAML file to create a PVC that specifies the StorageClass, save the sample as lvm-local-storage.yaml, and then run the kubectl apply -f lvm-local-storage.yaml command. The sample creates both the PVC and the Deployment. Each PVC corresponds to one logical volume on the node. After the pod is created on a node whose local disks are added to the VG, the logical volume is mounted.
The default storageClassName of the cluster is csi-local-lvm.
An LVM local volume stores data on the disks of the node where the pod runs, and the data lifecycle is bound to that node. Note the following limits:
-
LVM local storage volumes do not support data migration across nodes. If the pod is rescheduled to another node, the pod cannot access the original data.
-
If the node fails, is stopped, or is removed from the cluster, all data on the local disks of the node is erased and cannot be recovered. Back up the data or implement redundancy at the application layer.
-
Local storage is not a high availability (HA) volume. It is suitable only for temporary data or for applications that have built-in HA. LVM volumes support capacity scale-out.
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
Check whether the logical volume is mounted. In the following commands, local-test-564dfcf6dc-qhfsf is an example pod name. Replace it with the name of your own pod, which you can obtain by running kubectl get pod -l k8s-app=local-test.
kubectl get pod -l k8s-app=local-test
kubectl exec -it local-test-564dfcf6dc-qhfsf -- sh
/ # ls /data
Expected output:
lost+found
The expected output indicates that the logical volume is mounted to the pod.