Using Parallel File System PFS
The Cloud Container Engine (CCE) supports the use of Baidu AI Cloud’s Parallel Filesystem Service (PFS) by creating PV/PVC and mounting data volumes for workloads. This document will introduce how to dynamically and statically mount parallel filesystem service in a cluster.
Usage restrictions
- Ensure the Kubernetes cluster version is 1.16 or above.
- The PFS instance must be within the same VPC as the cluster.
- Currently, PFS does not support clusters with arm architecture and nodes running OSs such as Ubuntu 18.04/16.04, baidulinux 3.0 and RockyLinux 8.6. If required for service scenarios, please Submit a Ticket.
Prerequisites
- The cluster has installed parallel filesystem service components. For more information, please refer to CCE CSI PFS Plugin Description.
Operation steps
Dynamically mount the parallel filesystem service
1. Create a StorageClass
Cluster administrators can define different storage classes for the cluster using StorageClass. By combining StorageClass with PVC, necessary storage resources can be dynamically created.
This document explains how to use Kubectl to create a StorageClass of the parallel filesystem service (PFS) type and customize the template required for its use.
You need to create a PFS instance first. For operation steps, refer to Create Parallel File System.
1kind: StorageClass
2apiVersion: storage.k8s.io/v1
3metadata:
4 name: pfs-sc
5provisioner: csi-clusterfileplugin
6allowVolumeExpansion: true
7parameters:
8 clusterIP: #Required, PFS instance connection address
9 clusterPort: #Required, the current port is fixed at "8888"
10 parentDir: #Required, a custom path is acceptable
2. Create a persistent volume claim (PVC)
Note: The storageClassName field must match the name of the StorageClass specified when deploying the StorageClass mentioned above.
1kind: PersistentVolumeClaim
2apiVersion: v1
3metadata:
4 name: csi-pvc-pfs
5 namespace: default
6spec:
7 accessModes:
8 - ReadWriteMany
9 storageClassName: pfs-sc
10 resources:
11 requests:
12 storage: 50Gi # Specify the PVC storage space size
3. Check that the PVC status is bound
1$ kubectl get pvc csi-pvc-pfs
2NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
3csi-pvc-pfs Bound pvc-1ab36e4d1d2711e9 50Gi RWX pfs-sc 4s
4. Mount the PVC in the Pod
The Pod and PVC must reside within the same namespace.
1apiVersion: v1
2kind: Pod
3metadata:
4 name: test-pvc-pod
5 namespace: default
6 labels:
7 app: test-pvc-pod
8spec:
9 containers:
10 - name: test-pvc-pod
11 image: nginx
12 volumeMounts:
13 - name: pfs-pvc
14 mountPath: "/pfs-volume"
15 volumes:
16 - name: pfs-pvc
17 persistentVolumeClaim:
18 claimName: csi-pvc-pfs
Statically mount the parallel filesystem service
1. Create a persistent volume (PV)
Specify the path to be mounted through pv.spec.csi.volumeAttributes.path; this path is the relative path of the filled-in parentDir path.
This document uses the path of PV in PFS as /exist/some/dir as an example. If the corresponding path does not exist, it will be automatically created when mounting the PV.
1apiVersion: v1
2kind: PersistentVolume
3metadata:
4 name: static-pv-pfs
5spec:
6 accessModes:
7 - ReadWriteMany
8 storageClassName:
9 capacity:
10 storage: 100Gi
11 csi:
12 driver: csi-clusterfileplugin
13 volumeHandle: data-id
14 volumeAttributes:
15 parentDir: / #Required, custom path
16 path: /exist/some/dir # Required, specify the path to be mounted as the directory of the PFS instance relative to parentDir
17 clusterIP: "" #Required, PFS instance connection address
18 clusterPort: "8888" #Required, The port is currently fixed to 8888
Description
- In a static PV, storageClassName is null and does not need to be provided.
- volumeHandle must be unique, which can be achieved by using the current timestamp (e.g., 2024-09-27-11-30-00-00) or generating a UUID.
- clusterPort is currently fixed at "8888"
2. Create a persistent volume claim (PVC)
1kind: PersistentVolumeClaim
2apiVersion: v1
3metadata:
4 name: static-pvc-pfs
5 namespace: default
6spec:
7 accessModes:
8 - ReadWriteMany
9 storageClassName:
10 resources:
11 requests:
12 storage: 100Gi
2. Check that the PVC status is bound and bound to the corresponding PV.
1$ kubectl get pvc
2NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
3static-pvc-pfs Bound static-pv-pfs 100Gi RWX pfs-static-sc 10s
3. Mount the PVC in the Pod
The Pod and PVC must reside within the same namespace.
1apiVersion: v1
2kind: Pod
3metadata:
4 name: test-pvc-pod
5 namespace: default
6 labels:
7 app: test-pvc-pod
8spec:
9 containers:
10 - name: test-pvc-pod
11 image: nginx
12 volumeMounts:
13 - name: pfs-pvc
14 mountPath: "/pfs-volume"
15 volumes:
16 - name: pfs-pvc
17 persistentVolumeClaim:
18 claimName: static-pvc-pfs
Connect multiple PFS instances
To enable support for multiple PFS instances, simply deploy another StorageClass and populate the clusterIP and parentDir fields with the details of the new PFS instance.
1. Add a storage class
1kind: StorageClass
2apiVersion: storage.k8s.io/v1
3metadata:
4 name: pfs-sc-2
5provisioner: csi-clusterfileplugin
6allowVolumeExpansion: true
7parameters:
8 clusterIP: #Required, PFS instance connection address
9 clusterPort: #Required, the current port is fixed at "8888"
10 parentDir: #Required, a custom path is acceptable
2.1 For dynamic mount, specify the storage class in the PVC as the newly created storageClassName
1kind: PersistentVolumeClaim
2apiVersion: v1
3metadata:
4 name: csi-pvc-pfs-2
5 namespace: default
6spec:
7 accessModes:
8 - ReadWriteMany
9 storageClassName: pfs-sc-2
10 resources:
11 requests:
12 storage: 50 Gi # Specify the PVC storage space
2.2 For static mounting, fill in the information related to another PFS instance in the PV parameters
1apiVersion: v1
2kind: PersistentVolume
3metadata:
4 name: static-pv-pfs
5spec:
6 accessModes:
7 - ReadWriteMany
8 storageClassName:
9 capacity:
10 storage: 100Gi
11 csi:
12 driver: csi-clusterfileplugin
13 volumeHandle: data-id
14 volumeAttributes:
15 parentDir: / #Required, custom path
16 path: /exist/some/dir # Required, specify the path to be mounted as the directory of the PFS instance relative to parentDir
17 clusterIP: "" #Required, PFS instance connection address
18 clusterPort: "8888" #Required, The port is currently fixed to 8888
PFS configuration item example
Example 1
1 parentDir:"/kubernetes"
If the above configuration is filled in when deploying the StorageClass or static PV, the path of the dynamically created PV in PFS will be /kubernetes/pvc-xxxx-xxxx-xxxx-xxxx; the path of the static PV in PFS must be under the /kubernetes path.
Example 2
1 parentDir:"/"
If the above configuration is filled in during installation, the path of the dynamically created PV in PFS will be /pvc-xxxx-xxxx-xxxx-xxxx; the path of the static PV in PFS must be under the / path.
