Managing CFS by Using PVs and PVCs

Last updated: 2020-10-20 15:57:49

    Operation Scenario

    Tencent Kubernetes Engine (TKE) allows you to create PersistentVolumes (PVs) and PersistentVolumeClaims (PVCs) and use existing PVCs when creating workloads and adding volumes so that you can manage a file system by using the PVs and PVCs.

    Note:

    Different regions support different file storage capabilities. You need to select a region based on your requirement. For more information, see Storage Class and Performance Specification.

    Preparations

    Installing the CFS add-on

    Note:

    If your cluster has been installed with the CFS-CSI add-on, skip this step.

    1. Log in to the TKE Console.
    2. Click Cluster in the left sidebar to go to the Cluster Management page.
    3. Click the ID of the cluster for which you want to create an add-on to go to the Cluster Details page.
    4. On the "Cluster Details" page, choose Add-On Management > Create to go to the Create an add-on page.
    5. On the Create an add-on page, select CFS and click Done.

      Creating a StorageClass via the console

      To statically create a PV of the file storage type, you need to bind an available StorageClass of the same type. For more information, see Creating a StorageClass via the Console.

      Creating file storage

    6. Log in to the Cloud File Storage console and go to the File System page.
    7. Click Create. On the Create File System page, set the parameters as required, as shown in the following figure.
      • Name: set a custom name. This document uses cfs-test as an example.
      • Region: select a region in which to create the file system and ensure that the file system and the cluster are in the same region.
      • Availability Zone: select an availability zone in which to create the file system.
      • Storage Class: select Standard Storage or High-Performance Storage. Different availability zones support different storage classes. For more information, see Available Regions.
      • File Service Protocol: select a protocol type for the file system. Valid values include NFS and CIFS/SMB.
        • NFS: better suited to Linux and Unix clients.
        • CIFS/SMB: better suited to Windows clients. This protocol was launched for commercial use on September 1, 2020. For more information, see Notes on Commercial Use of CIFS/SMB.
      • Client Type: select the type of client that needs to access the file system. The value can be CVM (including TKE and BatchCompute) or CPM. Since CVM and CPM hosts belong to different networks, the system will allocate the file system to a specified network based on your client type.
      • Network Type: select Virtual Private Cloud so that CVM hosts can share the file system in a VPC.
      • Select Network: select a network to ensure that the file system and the cluster that uses the file system are in the same VPC.
      • Permission Group: each file system must be bound to a permission group. The permission group specifies an allowlist that can access the file system and lists the read and write permissions.
      • Tag:
        • If you have a tag, you can add it to the file system.
        • If you do not have a tag, log in to the Tag console to create the required tag, and then bind the tag to the file system. You can also add a tag to the file system after the file system is created.
    8. Click Create and wait until the file system is created.

    Obtaining the subdirectory of the file system

    1. On the File System page, click the ID of the file system for which you want to obtain the destination subdirectory. The details page of the file system appears.
    2. Select the Mount Point Info tab and obtain the subdirectory /subfolder of this file system from Mount in Linux, as shown in the following figure.
      • localfolder: indicates the local directory that you created.
      • subfolder: it indicates a subdirectory that you created in the CFS file system. The subdirectory of the file system is /subfolder.

    Directions

    Creating a PV statically

    Note:

    A statically created PV is suitable for scenarios where file storage already contains data and is used in a cluster.

    1. Log in to the TKE console and click Cluster in the left sidebar.
    2. On the Cluster Management page, select the ID of the cluster where the PV needs to be created. The cluster management page of the PV to create appears.
    3. Choose Storage > PersistentVolume in the left sidebar to go to the PersistentVolume page, as shown in the following figure.
    4. Click Create to go to the Create PersistentVolume page, where you can set PV parameters as required, as shown in the following figure.
    • Creation Method: select Static.
    • Name: set a custom name. This document uses cfs-pv as an example.
    • Provisioner: select Cloud File Storage.
    • R/W permission: CFS only supports multi-host read and write.
    • StorageClass: select a StorageClass as required. This document uses cfs-storageclass, which you created in the step of Creating a StorageClass via the console, as an example.

      Note:

      • The PVC and PV will be bound to the same StorageClass.
      • If you do not specify a StorageClass, the value of StorageClass for the corresponding PV is empty, and the value of the storageClassName field in the corresponding YAML file is a null string.
    • Select CFS: ensure that the CFS and the current cluster are in the same VPC. This document uses cfs-test, which you created in the step of Creating CFS, as an example.
    • CFS Subfolder: enter the file system subdirectory that you obtained in the step of Obtaining the file system subdirectory. This document uses /subfolder as an example.
    1. Click Create a PersistentVolume.

    Creating a PVC

    1. On the details page of the target cluster, choose Storage > PersistentVolumeClaim in the left sidebar to go to the PersistentVolumeClaim page, as shown in the following figure.

    2. Click Create to go to the Create a PersistentVolumeClaim page, where you can set key PVC parameters as required, as shown in the following figure.

      • Name: set a custom name. This document uses cfs-pvc as an example.
      • Namespace: select default.
      • Provisioner: select Cloud File Storage.
      • R/W permission: CFS only supports multi-host read and write.
      • StorageClass: select a StorageClass as required. This document uses cfs-storageclass, which you created in the step of Creating a StorageClass via the console, as an example.

        Note:

        • The PVC and PV will be bound to the same StorageClass.
        • If you do not specify a StorageClass, the value of StorageClass for the corresponding PVC is empty, and the value of the storageClassName field in the corresponding YAML file is a null string.
    • PersistVolume: specify a PersistentVolume as required. This document uses the cfs-pv created in the Creating a PV statically step as an example.

      Note:

      • Only PVs in the specified StorageClass and in the Available or Released status can be selected. If no PV in the current cluster meets the conditions, select “No PersistVolume is specified”.
      • If the status of the selected PV is Released, you need to manually delete the claimRef field in the corresponding YAML configuration file of the PV, so that the PV can be successfully bound with the PVC. For more information, see Viewing the rules for binding PVs and PVCs.
    1. Click Create a PersistentVolumeClaim to complete the creation process.

    Creating a workload to use a PVC volume

    Note:

    This step creates a Deployment workload as an example.

    1. On the Cluster Management page, select the target cluster ID to go to the Deployment page of the cluster for which the workload needs to be deployed.
    2. Click Create to go to the Create Workload page. For more information on how to create a workload, see Creating a Deployment. Then, mount a volume as required, as shown in the following figure.
      • Volume (optional):
        • Mount method: select Use existing PVC.
        • Volume name: set a custom name. This document uses cfs-vol as an example.
        • Select PVC: select cfs-pvc, which you created in the step of Creating a PVC.
      • Containers in the pod: click Add Mount Point to set a mount point.
        • Volume: select the volume cfs-vol that you added in this step.
        • Destination Path: enter a destination path. This document uses /cache as an example.
        • Sub-path: mount only a sub-path or a single file in the selected volume, such as /data or /test.txt.
    3. Click Create Workload to complete the creation process.

      Note:

      If you use the PVC mount method, the volume can be mounted to only one node.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help