This topic describes how to mount a Cloud Parallel File Storage (CPFS) AI-Computing Edition file system to a CPU pod in an Alibaba Cloud Container Service for Kubernetes (ACK) cluster.
Create a CPFS mount target
In the CPFS console, create a CPFS AI-Computing Edition file system instance and add a mount target to the VPC associated with your ACK cluster.
You can mount CPFS file systems only on CPU workloads (general-purpose and performance).
Log on to the File System Console and select the target region from the top navigation bar.
On the File System List page, find your CPFS file system. If its Mount Target count is 0, continue to the next step. Otherwise, skip to step 4.
In the row of the target file system, click Add in the Mount Target column. In the dialog box that appears, select the VPC and vSwitch for your ACK cluster and click OK. Wait for the mount target to be created.
On the cluster details page, you can view the VPC associated with ACS on the Basic Information tab in the Cluster Information section.
Click the file system's ID to navigate to the Mounting > Mount Target page. In the Mount Target column, click the copy icon to copy the mount target address. The address is in a format similar to the following:
cpfs-xxxxxxxxxxxx-vpc-xxxxxxx.cn-wulanchabu.cpfs.aliyuncs.com.
Create PV and PVC for CPFS
You need to replace the mount target address in the spec.csi.volumeAttributes.server field of the YAML file. Save the content as a YAML file, and then run the kubectl apply -f command.
apiVersion: v1
kind: PersistentVolume
metadata:
name: bmcpfs-vpc
labels:
alicloud-pvname: bmcpfs-vpc
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 100Gi
storageClassName: test # A custom name used to manually bind the PV and PVC. You do not need to create a StorageClass resource beforehand.
csi:
driver: nasplugin.csi.alibabacloud.com
volumeAttributes:
mountProtocol: efc
path: "/"
# Required: Replace with the mount target address from the previous step.
server: "cpfs-xxxxxxxxxxxx-vpc-xxxxxxx.cn-wulanchabu.cpfs.aliyuncs.com"
volumeHandle: bmcpfs-vpc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: bmcpfs-vpc
spec:
selector:
matchLabels:
alicloud-pvname: bmcpfs-vpc
accessModes:
- ReadWriteMany
storageClassName: test
volumeName: bmcpfs-vpc
resources:
requests:
storage: 100GiCreate a workload and associate the PVC
The following is a Deployment example that mounts the CPFS PVC (bmcpfs-vpc) created in Step 2, where the mount path in the container is /mnt.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
alibabacloud.com/compute-class: general-purpose
alibabacloud.com/compute-qos: default
app: test
spec:
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: topology.kubernetes.io/zone
# operator: In
# values:
# - cn-wulanchabu-c # For optimal performance, make sure the pod runs in the same availability zone as the CPFS file system.
containers:
- command:
- sleep
- infinity
image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
imagePullPolicy: Always
name: test
resources:
requests:
cpu: 500m
memory: 512Mi
volumeMounts:
- mountPath: /mnt
name: cpfs
volumes:
- name: cpfs
persistentVolumeClaim:
claimName: bmcpfs-vpc