Edge Local Storage
1. Check the local storage resources on the node
Check the corresponding Relation between existing block devices and nodes.
2. Create Configmap
Create a ConfigMap in a cluster. Here is a relatively generic ConfigMap configuration that configures local storage resources. For details, see DOC
apiVersion: v1kind: ConfigMapmetadata:name: node-resource-toponamespace: kube-systemdata:volumegroup: |-volumegroup:- name: volumegroup1key: kubernetes.io/hostnameoperator: Invalue: cn-zhangjiakou.192.168.3.114topology:type: devicedevices:- /dev/vdb- /dev/vdcquotapath: |-quotapath:- name: /mnt/path1key: kubernetes.io/hostnameoperator: Invalue: cn-beijing.192.168.3.35topology:type: deviceoptions: prjquotafstype: ext4devices:- /dev/vdb
The previous configuration provides the following functionsThe previous configuration provides the following functions
In the test cluster, we used two pieces of equipment : /dev/VDB & / dev/VDC to create an LVM volumegroup on the worker node: “cn - zhangjiakou. 192.168.3.114 “. Devices here can add paths that do not exist, because the plug-in will automatically ignore this path during the node initialisation.
Meanwhile, we format the block device “/dev/vdb” to prjquota format on worker node “cn-beijing.192.168.3.35”, and mount it to path “/mnt/path1”, and then subdirectories created under this path can set the maximum quota for each directory. Devices here can also add paths that do not exist, the component will automatically select the first existing block device for formatting and binding.
3. Install node-resource-manager
kubectl apply -f https://raw.githubusercontent.com/openyurtio/node-resource-manager/main/deploy/nrm.yaml
4. Deploy application in cluster(with lvm)
Create storageclass
cat <<EOF | kubectl apply -f -apiVersion: storage.k8s.io/v1kind: StorageClassmetadata:name: csi-localprovisioner: localplugin.csi.alibabacloud.comparameters:volumeType: LVMvgName: volumegroup1fsType: ext4lvmType: "striping"reclaimPolicy: DeletevolumeBindingMode: WaitForFirstConsumerallowVolumeExpansion: trueEOF
Parameters. vgName is the VolumeGroup defined in node-resource-topo configmap, named volumegroup1.
Create PVC
cat << EOF | kubectl apply -f -apiVersion: v1kind: PersistentVolumeClaimmetadata:name: lvm-pvcannotations:volume.kubernetes.io/selected-node: cn-zhangjiakou.192.168.3.114spec:accessModes:- ReadWriteOnceresources:requests:storage: 2GistorageClassName: csi-localEOF
You need to specify the node where the storage is located in the PVC’s annotation,
Create application
cat << EOF | kubectl apply -f -apiVersion: apps/v1kind: Deploymentmetadata:name: deployment-lvmlabels:app: nginxspec:selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:1.7.9volumeMounts:- name: lvm-pvcmountPath: "/data"volumes:- name: lvm-pvcpersistentVolumeClaim:claimName: lvm-pvcEOF
Above, we have completed the basic use of local storage, Quotapath mode is basically the same, just need to change the StorageClass.
