tencent cloud

Feedback

Using CFS on TKE

Last updated: 2024-01-22 22:15:48

    Overview

    CFS is suitable for two use cases in a container environment:

    Use case 1. Persistent storage of Pod/container data (dynamic mounting of CFS recommended)

    CFS provides a space for persistent storage where the data is still stored when a Pod or container is terminated. In this way, the original space can be quickly mounted through PVCs to implement data reads/writes quickly when another Pod or container is started. Compared with other schemes, a single-FS instance allows you to store the data from multiple Pods or containers and assign different subdirectories in the CFS instance to different Pods. Standard and High-Performance CFS instances are pay-as-you-go with no requirement for the minimum purchase capacity. This helps reduce the costs of persistent data storage for large-scale containers.

    Use case 2. Multi-Pod/container data sharing (static mounting of CFS recommended)

    CFS provides shared access to a directory space from multiple Pods or containers over NFS or private protocols for efficient data sharing. Compared with other schemes, this provides higher bandwidth and IOPS capabilities.
    This section describes how to deploy a container workload in the Tencent Cloud console. For more information on how to write a YAML file, refer to the YAML file automatically generated after a StorageClass is created in the console.
    Note:
    Make sure that the CSI component in the TKE cluster is on v1.0.4 or later; otherwise, update it in the TKE console. The update operation does not affect the normal use of the container.

    Directions

    Dynamically mounting CFS

    Note:
    This mounting option is recommended for persistent storage of Pod/container data.
    1. Create a StorageClass as instructed in Managing CFS Templates by Using a StorageClass.
    
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Instance creation mode
    Select Shared instance.
    Availability zone
    We recommend you select the same AZ as that of the container host.
    Storage type
    Select Standard storage or Performance storage as needed.
    Protocol version
    Unless in scenarios involving concurrent modifications, we recommend you use the NFS v3 protocol for better performance.
    Reclaim policy
    Select Delete or Retain as needed. To avoid unexpected data deletion, we recommend you select Retain.
    2. Create a PVC as instructed in Managing CFS by Using PVs and PVCs.
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Namespace
    Select a namespace as needed.
    StorageClass
    Select the StorageClass you just created.
    PersistentVolume
    You don't need to specify a PV for dynamic creation. Note: For a StorageClass based on a shared CFS instance, if you don't specify a PV when creating a PVC, the CSI plugin will automatically create a pay-as-you-go CFS instance when creating a PVC. This instance will be deleted when the PVC is deleted. Therefore, process PVCs created in this way with caution.
    3. Create a Deployment as instructed in Deployment Management.
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Volume
    Name the volume as needed and select the PVC you just created.
    Mount point
    Select the volume and specify the path for mounting to the container. When you dynamically create a shared CFS instance, you need to specify an environment variable, and the CSI plugin will create a directory in the CFS instance corresponding to the selected PVC based on the value of the configured environment variable for the container to mount.
    After completing the configuration, click Create Workload, and the system will create a container based on this configuration and mount CFS.

    Statically mounting CFS

    Note:
    This mounting option is recommended for multi-Pod/container data sharing.
    1. Create a StorageClass as instructed in Managing CFS Templates by Using a StorageClass.
    
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Instance creation mode
    Select Shared instance.
    Availability zone
    We recommend you select the same AZ as that of the container host.
    Storage type
    Select Standard storage or Performance storage as needed.
    Protocol version
    Unless in scenarios involving concurrent modifications, we recommend you use the NFS v3 protocol for better performance.
    Reclaim policy
    Select Delete or Retain as needed. To avoid unexpected data deletion, we recommend you select Retain.
    2. Create a PV as instructed in Managing CFS by Using PVs and PVCs.
    
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Creation method
    Select Manual; that is, specify a CFS instance for PV configuration.
    StorgeClass
    Select the StorageClass you just created.
    Select CFS
    Select a specified CFS instance. Note: During static creation, make sure that you already have a CFS instance in the same VPC as the container.
    CFS subdirectory
    CFS allows you to mount subdirectories. You can select different subdirectories and bind them to one or multiple PVs as needed to implement different degrees of data sharing.
    3. Create a PVC as instructed in Managing CFS by Using PVs and PVCs.
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Namespace
    Select a namespace as needed.
    StorageClass
    Select the StorageClass you just created.
    PersistentVolume
    Select Specify and select the PV you just created.
    4. Create a Deployment as instructed in Deployment Management.
    
    
    Key configuration items are as described below:
    Configuration Item
    Description
    Volume
    Name the volume as needed and select the PVC you just created.
    Mount point
    Select the volume and specify the path for mounting to the container. To achieve automatic subdirectory creation, you can use two methods. Method 1: Select subPath as the mount point and enter the name of the path you want to mount, such as test. Then, the CSI plugin will automatically create the test directory under the root path of the file system and automatically mount it to the specified directory of the container. Method 2: Add an environment variable and assign a value to it. Select subPathExpr as the mount point and select the environment variable. The CSI plugin will use the value of the environment variable as the directory name, automatically create the directory under the root path of the file system, and automatically mount it to the specified directory of the container.
    After completing the configuration, click Create Workload, and the system will create a container based on this configuration and mount CFS.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support