Using RapidFS
The Cloud Container Engine (CCE) supports the use of Baidu AI Cloud’s RapidFS by creating PV/PVC and mounting data volumes for workloads. This document will introduce how to dynamically and statically mount RapidFS in a cluster.
Usage restrictions
- The cluster's Kubernetes version must be 1.18 or above.
- RapidFS instances must reside within the same VPC as the cluster.
Prerequisites
- Create a RapidFS instance in the RapidFS console. For specific operations, please refer to Create New Cache Instance.
- Add and import a data source in the RapidFS console. For specific operations, please refer to Import Data Source.
- In the CCE console, use the "cce-csi-rapidfs-plugin" template under Helm Templates - Baidu AI Cloud Templates to install the RapidFS component in the target cluster.
- Nodes mounting RapidFS data sources need to set the root path to the
sharedmount mode. That is, you need to execute the commandmount --make-rshared /on the corresponding server.
Operation steps
Dynamically mount RapidFS
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 create a RapidFS StorageClass with Kubectl and tailor the template for utilizing RapidFS storage.
1kind: StorageClass
2apiVersion: storage.k8s.io/v1
3metadata:
4 name: rapidfs-sc
5provisioner: csi-rapidfsplugin
6parameters:
7 rapidfsAddress: #Required, the domain name of a mount target of the target data source. The RapidFS instance associated with the data source must be in the same VPC as the cluster
8 rapidfsID: #Required, the ID of the RapidFS instance associated with the data source
Note:
- The permission group linked to the data source, corresponding to the domain name of a mount target, must be set with access permissions (either read-only or read-write) for Pods in the cluster. Otherwise, the container will not be able to perform read or write operations. You can configure the VPC network segment of the K8S Cluster CCE directly or associate it with the default permission group.
When mounting a RapidFS PV for a Pod, a fuse pod is created by default for mounting. It supports customizing Fuse Pod-related configurations to meet flexible service needs;
It’s advisable to use default values for the following parameters unless there are specific requirements. Configuring a CPU or memory that’s too small may impact the performance or reliability of accessing RapidFS storage.
1parameters:
2 memRequest: 4 Gi #Optional, specify the request value for fuse pod memory, default to 4Gi
3 memLimit: 64 Gi #Optional, specify the upper limit value for fuse pod memory, default to 64 Gi
4 cpuRequest: 4000 m #Optional, specify the request value for fuse pod cpu, default to 4000 m
5 cpuLimit: 16000 m #Optional, specify the request value for fuse pod cpu, default to 16000
6 mountOptions: "" #Optional, fuse pod startup parameters. Multiple parameters are separated by commas. When EnableNuma=1 is set, the mounting process will bypass and bind to the same numa node as the local IP network interface card (only 0 or 1 can be set; 0 means no binding). You can add the parameter "EnableNuma=1,NumaNode=x" to specify the numa node to bind, where x is the server numa node to be bound
7 mountEnv: "" #Optional, fuse pod environment variable configuration, default is null. Multiple environment variables are separated by commas
Description:
- Fuse pod: Used to mount the data source to a node's local path; the user’s container accesses the data source through this fuse pod.
- The above are optional configuration parameters for the fuse pod. If left unset, default values will be automatically applied.
2. Create a persistent volume claim (PVC)
The storageClassName field must specify the name of the storageClass that was defined when deploying the said storageClass.
1kind: PersistentVolumeClaim
2apiVersion: v1
3metadata:
4 name: csi-pvc-rapidfs
5 namespace: default
6spec:
7 accessModes:
8 - ReadWriteMany
9 storageClassName: rapidfs-sc # Need to specify the name filled in when deploying the storageClass as mentioned above
10 resources:
11 requests:
12 storage: 50 Gi # User-specified PVC storage space (Note: RapidFS does not support limiting storage usage. The actual accessible content of the container is the BOS bucket directory bound to the data source.)
3. Check that the PVC status is bound
1$ kubectl get pvc csi-pvc-rapidfs
2NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
3csi-pvc-rapidfs Bound pvc-1ab36e4d1d2711e9 50Gi RWX rapidfs-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 # The Pod and PVC are in the same namespace
6 labels:
7 app: test-pvc-pod
8spec:
9 containers:
10 - name: test-pvc-pod
11 image: nginx
12 volumeMounts:
13 - name: rapidfs-pvc
14 mountPath: "/rapidfs-volume"
15 volumes:
16 - name: rapidfs-pvc
17 persistentVolumeClaim:
18 claimName: csi-pvc-rapidfs
Statically mount RapidFS
1. Create a persistent volume (PV)
1apiVersion: v1
2kind: PersistentVolume
3metadata:
4 name: static-pv-rapidfs
5spec:
6 accessModes:
7 - ReadWriteMany
8 storageClassName: # storageClassName is null in the static PV and does not need to be filled in
9 capacity:
10 storage: 100Gi
11 csi:
12 driver: csi-rapidfsplugin
13 volumeHandle:
14 volumeAttributes:
15 rapidfsAddress: #Required, the domain name of a mount target of the target data source. The RapidFS instance associated with the data source must be in the same VPC as the cluster
16 rapidfsID: #Required, the ID of the RapidFS instance associated with the data source
Note:
- The permission group linked to the data source, corresponding to the domain name of a mount target, must be set with access permissions (either read-only or read-write) for Pods in the cluster. Otherwise, the container will not be able to perform read or write operations. You can configure the VPC network segment of the K8S Cluster CCE directly or associate it with the default permission group.
When mounting a RapidFS PV for a Pod, a fuse pod is created by default for mounting. It supports customizing Fuse Pod-related configurations to meet flexible service needs;
It’s advisable to use default values for the following parameters unless there are specific requirements. Configuring a CPU or memory that’s too small may impact the performance or reliability of accessing RapidFS storage.
1volumeAttributes:
2 memRequest: 4 Gi #Optional, specify the request value for fuse pod memory, default to 4Gi
3 memLimit: 64 Gi #Optional, specify the upper limit value for fuse pod memory, default to 64 Gi
4 cpuRequest: 4000 m #Optional, specify the request value for fuse pod cpu, default to 4000 m
5 cpuLimit: 16000m #Optional, specify the request value for fuse pod cpu, default to 16000m
6 mountOptions: "" #Optional, fuse pod startup parameters. Multiple parameters are separated by commas. When EnableNuma=1 is set, the mounting process will bypass and bind to the same numa node as the local IP network interface card (only 0 or 1 can be set; 0 means no binding). You can add the parameter "EnableNuma=1,NumaNode=x" to specify the numa node to bind, where x is the server numa node to be bound
7 mountEnv: "" #Optional, fuse pod environment variable configuration, default is null. Multiple environment variables are separated by commas
Note:
- Fuse pod: Used to mount the data source to a node's local path; the user’s container accesses the data source through this fuse pod.
- The above are optional configuration parameters for the fuse pod. If left unset, default values will be automatically applied.
2. Create a persistent volume claim (PVC)
1apiVersion: v1
2kind: PersistentVolumeClaim
3metadata:
4 Name: static-pvc-rapidfs # Specify the PVC name
5spec:
6 volumeName: static-pv-rapidfs # Specify the PV name, and ensure that it is consistent with the above PV
7 accessModes:
8 - ReadWriteMany
9 resources:
10 requests:
11 storage: 100 Gi # User-specified PVC storage space (Note: RapidFS does not support limiting storage usage. The actual accessible content of the container is the BOS bucket directory bound to the data source.)
2. Check that the PVC status is bound and bound to the corresponding PV.
1$ kubectl get pvc static-pvc-rapidfs
2NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
3static-pvc-rapidfs Bound static-pv-rapidfs 100Gi RWX rapidfs-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 # The Pod and PVC are in the same namespace
6 labels:
7 app: test-pvc-pod
8spec:
9 containers:
10 - name: test-pvc-pod
11 image: nginx
12 volumeMounts:
13 - name: rapidfs-pvc
14 mountPath: "/rapidfs-volume"
15 volumes:
16 - name: rapidfs-pvc
17 persistentVolumeClaim:
18 claimName: csi-pvc-rapidfs
