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.
a43qadkl
as shown below:Note: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.
Log in to the TKE console and select Cluster on the left sidebar.
On the Cluster management page, click the ID of the target cluster to go to the cluster details page.
Select Storage > StorageClass on the left sidebar.
Click Create to enter the Create StorageClass page, where you can configure StorageClass parameters.
Configuration Item | Description |
---|---|
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.
|
AZ | 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 over 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.
|
Label | 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 creation, the parameters of the bound tag cannot be modified. If the existing tags are not suitable, create one in the Tag console. |
Click Create StorageClass to complete the process.
On the Cluster management page, select the ID of the cluster for which a PVC needs to be created.
On the cluster details page, select Storage > PersistentVolumeClaim on the left sidebar.
Click Create to enter the Create PersistentVolumeClaim page, where you can set key PVC parameters.
Configuration Item | Description |
---|---|
Name | Enter the `PersistentVolumeClaim` name, for example, `cfs-pvc`. |
Namespaces | A namespace is used to assign cluster resources. Here, default is selected. |
Provisioner | Select Cloud File Storage. |
Read/write 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.
|
Click Create PersistentVolumeClaim.
Note:This step creates a Deployment workload as an example.
cfs-vol
as an example.cfs-pvc
, which you created in the step of Creating a PVC.cfs-vol
that you added in this step./cache
as an example./data
or /test.txt
.Note: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:
Parameter | Required | Description |
---|---|---|
zone | No | It defines the region for the CFS instance. |
pgroupid | No | It defines the permission group for the CFS instance. |
storagetype | No | It defaults to Standard Storage (SD). Valid values: SD (Standard Storage) HP (High-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 comma. 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 # You don't need to specify it for dynamic creation. For static creation, you need to specify the PV instance ID.
Parameter | Required | Description |
---|---|---|
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. |
Note:
- 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.
Was this page helpful?