# Using SFS Volumes

#### Prerequisites

You have created a CCE cluster and installed the FlexVolume plug-in (storage-driver) in the cluster.

#### Notes and Constraints

- SFS volumes are available only in certain regions.
- Container storage in CCE clusters of Kubernetes 1.13 or later version supports encryption. Currently, E2E encryption is supported only in certain regions.
- Volumes cannot be created in specified enterprise projects. Only the default enterprise project is supported.

#### Creating an SFS Volume

1. Log in to the CCE console. In the navigation pane, choose Resource Management > Storage.
2. On the SFS tab, click Create SFS File System.
3. Configure basic information, as shown in Table 1.

   Table 1 Parameters for Creating a File System Volume
   Parameter | Parameter Description
   --- | ---
   * PVC Name | Name of the new PVC, which is different from the volume name. The actual volume name is automatically generated when the PV is created by the PVC.
   Cluster Name | Cluster to which the file system volume belongs.
   Namespace | Namespace with which the snapshot is associated.
   Total Capacity | The total capacity is the capacity of a single volume. Fees are charged by actual usage.

   Access Mode

   Access permissions of user applications on storage resources (PVs).
   - ReadWriteMany (RWX): The SFS volume can be mounted as read-write by multiple nodes.

   Encryption

   KMS Encryption is deselected by default.

   After KMS Encryption is selected, Key Management Service (KMS), an easy-to-use and highly secure key service, will be used for SFS file systems. If no agency has been created, click Create Agency and set the following parameters:
   - Agency Name: Agencies can be used to assign permissions to trusted accounts or cloud services for a specific period of time. If no agency is created, click Create Agency. The agency name SFSAccessKMS indicates that SFS is granted the permission to access KMS. After SFS is authorized successfully, it can obtain KMS keys to encrypt and decrypt file systems.
   - Key Name: After a key is created, it can be loaded and used in containerized applications.
   - Key ID: generated by default.

   This function is supported only for clusters of v1.13.10 and later in certain regions.

4. Click Create.

   The volume is displayed in the list. When PVS Status becomes Bound, the volume is created successfully.

5. Click the volume name to view detailed information about the volume.

#### Adding an SFS Volume

1. Create a workload or job by referring to Creating a Deployment, Creating a StatefulSet, Creating a DaemonSet, or Creating a Job. During creation, expand Data Storage after adding a container. On the Cloud Volume tab page, click Add Cloud Volume.
2. Set the storage class to SFS.

   Table 2 Parameters for mounting a file system
   Parameter | Parameter Description
   --- | ---
   Type | File Storage (NFS): This type applies to a wide range of scenarios, including media processing, content management, big data, and application analysis.
   Allocation Mode

   Manual

   - Name: Select a created file system. You need to create a file system in advance. For details about how to create a file system, see Creating an SFS Volume.
   - Sub-Type: subtype of the created file storage.
   - Storage Capacity: This field is one of the PVC attributes. If the storage capacity has been expanded on the IaaS side, it is normal that the capacity values are inconsistent. The PVC capacity is the same as the storage entity capacity only after end-to-end container storage capacity expansion is supported for CCE clusters of v1.13.

   Automatic

   An SFS volume is created automatically. You need to enter the storage capacity.
   - Sub-Type: Select NFS.
   - Storage Capacity: Specify the total storage capacity, in GB. Ensure that the storage capacity quota is not exceeded; otherwise, creation will fail.
   - After you select KMS Encryption, Key Management Service (KMS), an easy-to-use and highly secure service, will be enabled for file systems. This function is supported only for clusters of v1.13.10 and later in certain regions. If no agency has been created, click Create Agency and set the following parameters:
     - Agency Name: Agencies can be used to assign permissions to trusted accounts or cloud services for a specific period of time. If no agency is created, click Create Agency. The agency name SFSAccessKMS indicates that SFS is granted the permission to access KMS. After SFS is authorized successfully, it can obtain KMS keys to encrypt and decrypt file systems.
     - Key Name: After a key is created, it can be loaded and used in containerized applications.
     - Key ID: generated by default.

   Add Container Path

   Configure the following parameters:
   1. subPath: Enter the subpath of the file storage, for example, /tmp.

      If this parameter is not specified, the root path of the data volume is used by default. Currently, only file storage is supported. The value must be a relative path and cannot start with a slash (/) or ../.

   2. Container Path: Enter the path of the container, for example, /tmp.
      The container path must not be a system directory, such as / and /var/run. Otherwise, an exception occurs. You are advised to mount the volume to an empty directory. If the directory is not empty, ensure that there are no files affecting container startup in the directory. Otherwise, such files will be replaced, resulting in failures to start the container and create the workload.
      NOTICE:

      If the volume is mounted to a high-risk directory, you are advised to use an account with minimum permissions to start the container; otherwise, high-risk files on the host machine may be damaged.

   3. Set permissions.
      - Read-only: You can only read the data volumes mounted to the path.
      - Read/Write: You can modify the data volumes mounted to the path. Newly written data is not migrated if the container is migrated, which may cause a data loss.

   Click Add Container Path to add multiple settings. Then, click OK.

3. Click OK.

#### Importing an SFS Volume

CCE allows you to import existing SFS volumes.

1. Log in to the CCE console. In the navigation pane, choose Resource Management > Storage. On the SFS tab page, click Import.
2. Select one or more SFS volumes that you want to attach.
3. Select the target cluster and namespace. Then, click OK.

#### Unbinding an SFS Volume

When an SFS volume is successfully created or imported, the volume is automatically bound to the current cluster. Other clusters can also use the volume. When the SFS volume is unbound from the cluster, other clusters can still import and use the volume.

If the SFS volume has been attached to a workload, the volume cannot be unbound from the cluster.

1. Log in to the CCE console. In the navigation pane, choose Resource Management > Storage. In the SFS volume list, click Unbind next to the target volume.
2. Confirm the unbinding, and click OK.

#### Related Operations

After an SFS volume is created, you can perform the operation described in Table 3.

Table 3 Other operations
Operation | Description
--- | ---

Deleting an SFS volume

1. Select the SFS volume to be deleted and click Delete in the Operation column.
2. Follow the prompts to delete the EVS disk.

Importing an SFS volume

CCE allows you to import existing SFS volumes.

1. On the SFS tab page, click Import.
2. Select one or more SFS volumes that you want to attach.
3. Select the target cluster and namespace.
4. Click Yes.

Parent topic: Using SFS File Systems as Storage Volumes