• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide 2.0
  4. Storage Management
  5. Using SFS File Systems

Using SFS File Systems

SFS file systems apply to a wide range of scenarios, including media processing, content management, big data, and analytic applications.

Creating a File System

  1. Log in to the CCE console. In the navigation pane, choose Resource Management > Storage.
  2. Click the SFS tab and then click Create.
  3. Configure basic information in the page, the meanings of the corresponding parameters as listed in Table 1.

    Table 1 Basic file storage information

    Parameter

    Description

    PVC Name

    Name of the PVC. A storage volume is automatically created when a PVC is created. One PVC corresponds to one storage volume. The name of a storage volume is automatically generated when a PVC is created.

    Cluster Name

    Cluster where the file storage is deployed.

    Namespace

    Namespace where the SFS is located.

    Total Capacity (GB)

    Volume of the file system to be created.

    Access Mode

    ReadWriteMany

  4. Click Create Now. Confirm order details, click Submit, click Back to Storage List, and wait until the SFS has been created successfully.
  5. After the SFS has been created successfully, the created storage is displayed in the storage list. If the storage status is Bound, the storage has been created successfully.
  6. Click the storage name. On the storage details page that is displayed, view the storage information such as the mounting details and creation time.

Using File Systems

  1. Create an application by following the procedure in section Creating a Stateless Application or section Creating a Stateful Application. On the Data Storage > Cloud Storage tab page, click Add Cloud Storage.
  2. Select SFS as the storage type.

    Table 2 Parameters for mounting file storage

    Parameter

    Description

    Storage Type

    SFS. This storage type applies to a wide range of scenarios, including media processing, content management, big data, and application analysis.

    Allocation Mode

    Manual

    Select an existing storage volume. If no storage volume is available, follow the prompts to create one.

    Automatic

    A storage volume is created automatically. You need to enter the storage capacity.

    NOTE:

    A storage volume that is created automatically will not be tagged.

    1. Select the storage subtype.

      The file storage subtype is NFS.

    2. Enter the storage capacity, measured in GB. Ensure that the storage capacity quota is not exceeded; otherwise, creation will fail.

    Add Container Path

    1. Click Add Container Path.
    2. Container Path: Enter the container path to which the data volume is mounted.
      NOTICE:
      • Do not mount a data volume to a system directory such as / or /var/run. This action may cause a container error to occur. You are advised to mount the data volume to an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup; otherwise, the files will be replaced, making it impossible for the container to be properly started. The application creation will fail.
      • When the data volume is mounted to a high-risk directory, you are advised to use a low-permission account to start the container; otherwise, high-risk files on the host machine may be damaged.
    3. Set permissions.
      • Read-only: only allows you to read data volumes in the container path.
      • Read/Write: allows you to modify the data volumes in the container path. However, newly written data will not be migrated during container migration.

  3. Click OK.

Attaching and Mounting File Storage Volumes

CCE allows you to import existing file storage 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 file storage volumes that you want to attach and mount.
  3. Click OK.

Unbinding an SFS File System

After an SFS file system is successfully created or imported, the SFS file system is automatically bound to the current cluster and cannot be used by other clusters. After the SFS file system is unbound from the cluster, other clusters can import and use the file system.

If the SFS file system has been mounted to an application, the SFS file system cannot be unbound from the cluster.

  1. Log in to the CCE console. In the navigation pane, choose Resource Management > Storage. In the file storage volume list, click Unbind next to the target file storage volume.
  2. In the dialog box that is displayed, click OK.

Creating a File System Using kubectl

CCE supports the creation of file storage in the form of PersistentVolumeClaim (PVC).

Prerequisites

You have configured the kubectl command and connected an ECS server to the cluster. For details, see Connecting to a Kubernetes Cluster Using kubectl.

Procedure

  1. Log in to the ECS server on which the kubectl commands have been configured. For details, see Logging In to a Linux ECS.
  2. Run the following commands to configure the pvc-sfs-auto-example.yaml file, which is used to create a PVC.

    touch pvc-sfs-auto-example.yaml

    vi pvc-sfs-auto-example.yaml

    The following shows an example of creating a file storage.

    apiVersion: v1  
    kind: PersistentVolumeClaim  
    metadata:  
      annotations:  
        volume.beta.kubernetes.io/storage-class: nfs-rw   
      name: pvc-sfs-auto-example  
      namespace: default  
    spec:  
      accessModes:  
      - ReadWriteMany  
      resources:  
        requests:  
          storage: 10Gi

    In the preceding example:

    • volume.beta.kubernetes.io/storage-class indicates the file storage type. Currently, the standard file protocol type (nfs-rw) is supported.
    • name indicates the name of the PVC to be created.
    • storage indicates the storage capacity in Gi.

  3. Run the following command to create a PVC.

    kubectl create -f pvc-sfs-auto-example.yaml

    After the command is executed, a file storage is created in the VPC to which the cluster belongs. Choose Resource Management > Storage > SFS or log in to the SFS console to view the file system.

Creating a PV/PVC for an Existing File System Using kubectl

CCE allows you to use an existing file system to create a PV and bind the PV to the PVC.

Prerequisites

You have configured the kubectl command and connected an ECS server to the cluster. For details, see Connecting to a Kubernetes Cluster Using kubectl

Procedure

  1. Log in to the SFS console, and obtain the ID of the file system.
  2. Log in to the ECS server on which the kubectl commands have been configured. For details, see Logging In to a Linux ECS.
  3. Run the following command to configure the pv-sfs-example.yaml file, which is used to create a PV.

    vi pv-sfs-example.yaml

    Copy the following yaml commands to the pv-sfs-example.yaml file.

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: pv-sfs-example
      namespace: default
    spec:
      accessModes:
      - ReadWriteMany
      capacity:
        storage: 10Gi
      flexVolume:
        driver: huawei.com/fuxinfs
        fsType: nfs
        options:
          deviceMountPath: sfs-nas1.eu-de.otc.t-systems.com:/share-73bdfafd
          fsType: nfs
          volumeID: f6976f9e-2493-419b-97ca-d7816008d91c
      persistentVolumeReclaimPolicy: Delete
      storageClassName: nfs-ro
    Parameter description:
    • driver indicates the driver for the storage to be mounted. Set this parameter to huawei.com/fuxinfs for file systems.
    • volumeID indicates the ID of the file system.
    • storage indicates the capacity of the file system.
    • storageClassName indicates the read/write mode (nfs-rw or nfs-ro) supported by the file system.

  1. Run the following command to create a PV.

    kubectl create -f pv-sfs-example.yaml

  2. Run the following commands to configure the pvc-sfs-example.yaml file, which is used to create a PVC.

    touch pvc-sfs-example.yaml

    vi pvc-sfs-example.yaml

    Copy the following yaml commands to the pvc-sfs-example.yaml file.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      annotations:
        volume.beta.kubernetes.io/storage-class: nfs-rw
        volume.beta.kubernetes.io/storage-provisioner: flexvolume-huawei.com/fuxinfs
      name: pvc-sfs-example
      namespace: default
    spec:
      accessModes:
      - ReadWriteMany
      resources:
        requests:
          storage: 10Gi
    Parameter description:
    • volume.beta.kubernetes.io/storage-class indicates the file system type. Currently, the file systems (nfs-rw and nfs-ro) compatible with the standard file protocol are supported.
    • volume.beta.kubernetes.io/storage-provisioner indicates the plug-in for creating the file system. This parameter is fixed to flexvolume-huawei.com/fuxinfs.
    • volumeName indicates the PV name.

  1. Run the following command to create a PVC.

    kubectl create -f pvc-sfs-example.yaml

Mounting a File System Using kubectl

  1. Run the following commands to configure the sfs-pod-example.yaml file, which is used to create a pod.

    touch sfs-pod-example.yaml

    vi sfs-pod-example.yaml

    The following shows an example of mounting file storage.

    apiVersion: extensions/v1beta1  
    kind: Deployment  
    metadata:  
      name: sfs-pod-example                                # Application name 
      namespace: default  
    spec:  
      replicas: 1  
      selector:  
        matchLabels:  
          app: sfs-pod-example  
      template:  
        metadata:  
          labels:  
            app: sfs-pod-example  
        spec:  
          containers:  
          - image: nginx:1.1  
            name: container-0  
            volumeMounts:  
            - mountPath: /tmp                                # Mounting path 
              name: pvc-sfs-example  
          restartPolicy: Always  
          volumes:  
          - name: pvc-sfs-example  
            persistentVolumeClaim:  
              claimName: pvc-sfs-auto-example                # Mount the PVC.

    In the preceding example:

    • name is the name of the pod to be created.
    • app is the name of a pod application.
    • mountPath is the mount path in a container. In the example, the mount path is /tmp.
    • spec.template.spec.containers.volumeMounts.name and spec.template.spec.volumes.name must be consistent because they have a mapping relationship.

  2. Run the following command to create a pod.

    kubectl create -f sfs-pod-example.yaml

    After the pod is created, choose Resource Management > Storage > SFS on the CCE console to view the binding relationship between the application and PVC.

Related Operations

After the file storage is created, you can perform the operation described in Table 3.
Table 3 Other operations

Operation

Description

Deleting a file storage

  1. Select the name of the storage to be deleted and click Delete in the Operation column.
  2. Follow the prompts to delete the file storage.