Docs
upfs
Operation Guide
Mount file system
K8s

Mount File System (K8s)

Step 1: Install the client

When mounting in K8s mode, you need to install the UPFS client on all work nodes of K8s first. Please check UPFS client installation for the client installation steps.

Step 2: Install the csi tool package

The csi tool package needs to be installed on the master node. The detailed steps are as follows:

  1. Obtain the csi tool package. Before obtaining the csi tool package, please confirm that the current K8s cluster has configured Eip for flexible external network. After confirming, execute the following command to get the csi tool package.
wget https://upfs-public.cn-bj.ufileos.com/csi-upfs.tar.gz
  1. Execute the following command to unzip the csi tool package.
tar zxvf csi-upfs.tar.gz
  1. Execute the following command under the node where kubectl is installed to install the csi tool package.
kubectl apply -f rbac-controller.yml
kubectl apply -f rbac-node.yml
kubectl apply -f csi-controller.yml
kubectl apply -f csi-node.yml
  1. Execute the following command to verify whether the installation is successful.
kubectl get po -A | grep upfs

If there is POD information and the status is Running, it means that the installation is successful.

Step 3: Create the UPFS file system K8s cluster configuration file

You need to create a UPFS file system K8s cluster configuration file on the master node. The detailed steps are as follows:

  1. Here you need to create a StorageClass and PVC. The content of the configuration file refers to the following content, and name the configuration file storageclass.yaml (the file name can be customized). Note the following points:

    • uri: File System URL (For the detailed rules of the URL, please see the file system URL part in Main Concepts)
    • path: The subdirectory for container to mount UPFS file system, default is /
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: csi-upfs
provisioner: upfs.csi.ucloud.cn
parameters:
  uri: 100.64.240.97:10109,100.64.240.95:10109/upfs-y0gprzs5a12
  path: /mnt
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: logupfs-claim
spec:
  storageClassName: csi-upfs
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi  # The theoretical limit of UPFS storage space is high, so the capacity parameters in PV and PVC have no actual significance, and the request information here will not actually take effect
  1. Run the following command to create StorageClass and PVC,
kubectl apply -f storageclass.yaml

Step 4: Create a POD to use the UPFS file system

You need to create a POD to use the UPFS file system on the master node. The detailed steps are as follows:

  1. Create a POD to use the UPFS file system. The content of the configuration file is referred to the following content, and name the configuration file pod.yaml (the file name can be customized). Pay attention to the following points:

    • containers: Configuration information, configured according to actual circumstances
    • mountPath: The path in containers to mount UPFS
    • claimName: Here you need to specify the name of the UPFS PVC created in step three
apiVersion: v1
kind: Pod
metadata:
  name: nginx-upfs
spec:
  containers:
    - name: nginx
      image: uhub.service.ucloud.cn/ucloud/nginx:latest
      ports:
        - containerPort: 80
      volumeMounts:
        - name: test
          mountPath: /data
  volumes:
    - name: test
      persistentVolumeClaim:
        claimName: logupfs-claim
  1. Run the following command to create the POD:
kubectl apply -f pod.yaml

UPFS supports multiple PODs to mount and access UPFS file systems, just create multiple POD configuration files as above.

Step 5: Verify if the POD is running normally

  1. Execute the following command to Enter the POD created in the last step.
kubectl exec -it <POD name> /bin/bash
  1. Execute the following command to check whether the file system is mounted. If the result includes the ID of the file system resource to be mounted in step three, it means that the mount is successful.
kubectl apply -f pod.yaml

If there is a problem with mounting the file system, please contact the technical support of UCloud Global in time.