A cluster admin can use StorageClass to define different storage classes for Tencent Kubernetes Engine (TKE) clusters. TKE provides the block storage StorageClass by default. You can use both StorageClass and PersistentVolumeClaim to dynamically create required storage resources.
This document describes how to create a StorageClass of the Cloud File Storage (CFS) type by using the console and Kubectl as well as how to customize the template required by CFS disks.
If your cluster has been installed with the CFS-CSI add-on, skip this step; otherwise, install it as instructed in CFS Instructions.
When creating a StorageClass, you need to set the CFS subnet to ensure that every AZ in the CFS's VPC has a suitable subnet. We recommend you create a subnet in advance as instructed in Creating Subnets.
When creating a StorageClass, you need to configure a suitable permission group for the file system. We recommend you create a permission group in advance as instructed in Managing Permissions.
FSIDnext to Mount under Linux, such as
For better stability, when you create a PV by YAML and use the NFSv3 protocol for mounting, you need to specify the FSID of the file system to be mounted.
|Name||Enter the StorageClass name, for example, `cfs-storageclass`.|
|Region||It is the region of the cluster by default.|
|Provisioner||Provisioner can be CBS (CSI) or Cloud File Storage. Here, Cloud File Storage is selected.|
|Instance creation mode||It can be New instance or Shared instance.
|Availability zone||In the current region, select an AZ that supports CFS. Different AZs in the same region support different storage classes. For more information, see Recommended Regions .|
|CFS subnet||Set the subnet range of the CFS in the current AZ.|
|Storage type||CFS provides Standard Storage and Performance Storage. Different AZs in the same region support different storage types. Select one as needed.
|File service protocol||It is **NFS** by default to allow for pass-through access to files and file systems on the server.|
|Protocol version||We recommend you use NFSv3 for better performance. If your application relies on file locking (that is, multiple CVM instances are needed to edit a file), use NFSv4 for mounting.|
|Permission group||Configure a permission group for the file system, which is used to manage the access and read/write permissions of clients that access the file system on the same network. Select a permission group as needed. If no such permission group is available, create one on the Permission Group page.|
|Reclaim policy||It can be Delete or Retain. The latter is recommended out of data security considerations.
|Tag||Select the cloud tag to be bound to the CFS instance. The tag will be automatically inherited by the CFS instance that is created dynamically by a StorageClass. After a StorageClass is created, the parameters of the bound tag cannot be modified. If the existing tags are not suitable, create one in the Tag console.|
|Name||Enter the `PersistentVolumeClaim` name, for example, `cfs-pvc`.|
|Namespace||A namespace is used to assign cluster resources. Here, default is selected.|
|Provisioner||Select Cloud File Storage.|
|R/W permission||CFS only supports **Multi-computer read and write**.|
|StorageClass||Specify the StorageClass as needed. Here, Specify is selected. `cfs-storageclass` created in the Creating a StorageClass step is used as an example.
|PersistentVolume||Specify the PersistentVolume as needed. Here, Do not specify is selected.
This step creates a Deployment workload as an example.
cfs-volas an example.
cfs-pvc, which you created in the step of Creating a PVC.
cfs-volthat you added in this step.
/cacheas an example.
If you use the PVC mount method of CFS, the volume can be mounted to multiple nodes.
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: cfs parameters: # subdir-share: "true" vpcid: vpc-xxxxxxxx subnetid: subnet-xxxxxxxx vers: "3" resourcetags: "" provisioner: com.tencent.cloud.csi.cfs reclaimPolicy: Delete volumeBindingMode: Immediate
The following parameters can be configured:
|zone||No||It defines the region of the file storage.|
|pgroupid||No||It defines the permission group for the file storage.|
|storagetype||No||It defaults to Standard Storage (SD). Valid values:
SD (Standard Storage)
HP (Performance Storage)
|subdir-share||Yes||It indicates the shared instance mode for instance creation by StorageClass.|
|vpcid||Yes||It indicates the ID of the VPC where the file is stored.|
|subnetid||Yes||It indicates the ID of the subnet where the file is stored.|
|vers||Yes||It indicates the version of the protocol used by the add-on to connect to the file system. The dynamically created PVs inherit this parameter. The versions "3" and "4" are supported.|
|resourcetags||Yes||It indicates the cloud tag of the file system. A corresponding Tencent Cloud tag is applied on the generated file system. Multiple tags are separated by commas. For example, "a:b,c:d".|
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cfs namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi storageClassName: cfs volumeMode: Filesystem volumeName: XXX
|spec.accessModes||No||The cfs storage supports Multiple-Read-Multiple-Write.|
|spec.resources.requests.storage||Yes||The storage capacity only depends on the type of the file system.|
- CFS supports expanding the storage capacity of the file system according to the file size. The requests and applications are not interrupted during the expansion. The default CFS instance capacity is 10 GiB, and the upper limit of the capacity depends on the product type. For details, see System Restrictions.
- The PVs dynamically created through a PVC inherit the parameters configured in StorageClass. The parameters are generated automatically by the storage add-on.