Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Cloud Container Engine_Autopilot/ User Guide/ Storage/ Scalable File Service/ Using an Existing File System Through a Static PV

Using an Existing File System Through a Static PV

Updated on 2025-02-27 GMT+08:00

SFS is a network-attached storage (NAS) that provides shared, scalable, and high-performance file storage. It applies to large-capacity expansion and cost-sensitive services. You can mount the PVs created from general-purpose file systems (formerly SFS 3.0) to pods in CCE Autopilot clusters for file storage. This section describes how to use an existing file system to statically create PVs and PVCs and implement data persistence and sharing in workloads.

Prerequisites

  • If you want to create a cluster using commands, kubectl has been used to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
  • You have created a general purpose file system (formerly SFS 3.0) that is in the same VPC as the cluster.
  • You have configured a VPC endpoint required by the general purpose file system (formerly SFS 3.0). For details, see Configuring a VPC Endpoint.

Constraints

  • Not all regions support volumes created from file systems. View the regions where SFS volumes are supported on the console. You can also view Function Overview to learn about all regions where SFS volumes are supported.
  • Multiple PVs can use the same general purpose file system (formerly SFS 3.0) if the following restrictions are meet:
    • All PVCs or PVs that use the same file system cannot be mounted to a pod. This will result in a pod startup failure because not all PVCs can be mounted to the pod due to the same volumeHandle values of these PVs.
    • The persistentVolumeReclaimPolicy parameter in the PVs should be set to Retain. If any other value is used, when a PV is deleted, the associated underlying SFS file system may be deleted. In this case, other PVs associated with the underlying file system malfunction.
    • When a file system is repeatedly used, enable isolation and protection for ReadWriteMany at the application layer to prevent data overwriting and loss.
  • If a general-purpose file system (formerly SFS 3.0) is used, the owner group and permission of the mount point cannot be modified.
  • If a general-purpose file system (formerly SFS 3.0) is used, there may be a latency when the PVCs or PVs are created or deleted. The billing duration depends on the time when the file systems are created or deleted on the SFS console.
  • If the reclamation policy of the volumes created from general purpose file systems (formerly SFS 3.0) is set to Delete, the volumes cannot be reclaimed automatically. Before deleting a PV or PVC, you are required to delete all files in the file systems manually.

Using the Console

  1. Log in to the CCE console and click the cluster name to access the cluster console.
  2. Statically create a PVC and PV.

    1. In the navigation pane on the left, choose Storage. Then click the PVCs tab. In the upper right corner, click Create PVC. In the displayed dialog box, configure the parameters.

      Parameter

      Description

      PVC Type

      In this example, select SFS.

      PVC Name

      Enter the PVC name, which must be unique in the same namespace.

      Creation Method

      • If underlying storage is available, create a PV or use an existing PV to statically create a PVC.
      • If no underlying storage is available, select Dynamically provision. For details, see Using an SFS File System Through a Dynamic PV.

      In this example, select Create new to create a PV and PVC at the same time on the console.

      PVa

      Select an existing PV in the cluster. Create a PV in advance. For details, see "Creating a storage volume" in Related Operations.

      You do not need to specify this parameter in this example.

      SFSb

      Click Select SFS. On the displayed page, select the SFS file system that meets your requirements and click OK.

      NOTE:

      Only general purpose file systems (formerly SFS 3.0) are supported.

      PV Nameb

      Enter the PV name, which must be unique in the same cluster.

      Access Modeb

      SFS volumes support only ReadWriteMany, indicating that a storage volume can be mounted to multiple pods in read/write mode. For details, see Volume Access Modes.

      Reclaim Policyb

      You can select Delete or Retain to specify the reclaim policy of the underlying storage when the PVC is deleted. For details, see PV Reclaim Policy.

      NOTE:

      If multiple PVs use the same underlying storage volume, use Retain to avoid cascading deletion of underlying volumes.

      Mount Optionsb

      Enter the mounting parameter key-value pairs. For details, see Configuring SFS Volume Mount Options.

      NOTE:

      a: The parameter is available when Creation Method is set to Use existing.

      b: The parameter is available when Creation Method is set to Create new.

    2. Click Create to create a PVC and a PV.

      In the navigation pane on the left, choose Storage. View the created PVC and PV on the PVCs and PVs tabs, respectively.

  3. Create a workload.

    1. In the navigation pane on the left, choose Workloads. Then click the Deployments tab.
    2. In the upper right corner, click Create Workload. On the displayed page, click Data Storage in the Container Settings area and click Add Volume to select PVC.
      Mount and use storage volumes, as shown in Table 1. For details about other parameters, see Workloads.
      Table 1 Mounting a storage volume

      Parameter

      Description

      PVC

      Select an existing SFS volume.

      Mount Path

      Enter a mount path, for example, /tmp.

      This parameter indicates the container path that the volume will be mounted to. Do not mount the volume to a system directory such as / or /var/run. This may cause container errors. Mount the volume to an empty directory. If the directory is not empty, ensure that there are no files that affect container startup. If there are such files, they will be replaced, which will lead to a container startup or workload creation failure.
      NOTICE:

      If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container, or high-risk files on the host may be damaged.

      Subpath

      Enter a subpath, for example, tmp, indicating that data in the mount path of the container is stored in the tmp directory of the storage volume.

      A subpath is used to mount a local volume so that the same volume is used in a single pod. If this parameter is left blank, the root path is used by default.

      Permission

      • Read-only: You can only read the data in the mounted volume.
      • Read-write: You can modify the volume mounted to the path. Newly written data will not be migrated if the container is migrated, which may cause data loss.

      In this example, the volume is mounted to the /data path of the container. The container data generated in this path is stored in the SFS file system.

    3. Configure other parameters and click Create Workload.

      After the workload is created, the data in the container mount directory will be persistently stored. Verify the storage by referring to Verifying Data Persistence and Sharing.

Using kubectl

  1. Use kubectl to connect to the cluster.
  2. Create a PV.

    1. Create the pv-sfs.yaml file.
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        annotations:
          pv.kubernetes.io/provisioned-by: everest-csi-provisioner
          everest.io/reclaim-policy: retain-volume-only      # (Optional) The underlying storage is retained when the PV is deleted.
        name: pv-sfs    # PV name.
      spec:
        accessModes:
        - ReadWriteMany      # Access mode. The value must be ReadWriteMany for SFS.
        capacity:
          storage: 1Gi     # SFS volume capacity.
        csi:
          driver: nas.csi.everest.io    # Dependent storage driver for the mounting
          fsType: nfs
          volumeHandle: <your_volume_id>   # Enter the name of the general purpose file system (formerly SFS 3.0) is used.
          volumeAttributes:
            everest.io/share-export-location: <your_location>  # Shared path of the SFS volume.
            storage.kubernetes.io/csiProvisionerIdentity: everest-csi-provisioner
            everest.io/sfs-version: sfs3.0       # A general-purpose file system (formerly SFS 3.0) is used for storage.
        persistentVolumeReclaimPolicy: Retain    # Reclaim policy.
        storageClassName: csi-sfs               # StorageClass name, where csi-sfs indicates general purpose file systems (formerly SFS 3.0).
        mountOptions: []                         # Mount options.
      Table 2 Key parameters

      Parameter

      Mandatory

      Description

      everest.io/reclaim-policy: retain-volume-only

      No

      Optional.

      Currently, only retain-volume-only is supported.

      This parameter is valid only when the reclaim policy is set to Delete. If the reclaim policy is Delete and the value is retain-volume-only, the associated PV is deleted while the underlying storage volume is retained, when a PVC is deleted.

      volumeHandle

      Yes

      If a general purpose file system (formerly SFS 3.0) is used, enter the name of the file system.

      everest.io/share-export-location

      Yes

      Shared path of the file system.

      A shared path is in the following format:

      {your_sfs30_name}.sfs3.{region}.myhuaweicloud.com:/{your_sfs30_name}

      mountOptions

      Yes

      Mount options.

      If this parameter is not specified, the following configurations are used by default. For details, see Configuring SFS Volume Mount Options.

      mountOptions:
      - vers=3
      - timeo=600
      - nolock
      - hard

      persistentVolumeReclaimPolicy

      Yes

      The Delete and Retain reclaim policies are supported. For details, see PV Reclaim Policy. If multiple PVs use the same SFS volume, use Retain to prevent the underlying volume from being deleted with a PV.

      Delete:

      • If everest.io/reclaim-policy is not specified, both the PV and SFS file system will be deleted when a PVC is deleted.
      • If everest.io/reclaim-policy is set to retain-volume-only, when a PVC is deleted, the PV will be deleted but the SFS file system will be retained.

      Retain: When a PVC is deleted, both the PV and underlying storage are retained. You need to manually delete these resources. After the PVC is deleted, the PV is in the Released state and cannot be bound to a PVC again.

      storage

      Yes

      Requested capacity in the PVC, in Gi.

      For SFS, this field is used only for verification (cannot be empty or 0). Its value is fixed at 1, and any value you set does not take effect for SFS file systems.

    2. Run the following command to create a PV:
      kubectl apply -f pv-sfs.yaml

  3. Create a PVC.

    1. Create the pvc-sfs.yaml file.
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: pvc-sfs
        namespace: default
        annotations:
          volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner
      spec:
        accessModes:
        - ReadWriteMany               # The value must be ReadWriteMany for SFS.
        resources:
          requests:
            storage: 1Gi               # SFS volume capacity.
        storageClassName: csi-sfs       # Storage class name, which must be the same as that of the PV.
        volumeName: pv-sfs    # PV name.
      Table 3 Key parameters

      Parameter

      Mandatory

      Description

      storage

      Yes

      Requested capacity in the PVC, in Gi.

      The value must be the same as the storage size of the existing PV.

      volumeName

      Yes

      PV name, which must be the same as the PV name in 2.a.

    2. Run the following command to create a PVC:
      kubectl apply -f pvc-sfs.yaml

  4. Create a workload.

    1. Create a file named web-demo.yaml. In this example, the SFS volume is mounted to the /data path.
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: web-demo
        namespace: default
      spec:
        replicas: 2
        selector:
          matchLabels:
            app: web-demo
        template:
          metadata:
            labels:
              app: web-demo
          spec:
            containers:
            - name: container-1
              image: nginx:latest
              volumeMounts:
              - name: pvc-sfs-volume    # Volume name, which must be the same as the volume name in the volumes field.
                mountPath: /data  # Location where the storage volume is mounted.
            imagePullSecrets:
              - name: default-secret
            volumes:
              - name: pvc-sfs-volume    # Volume name, which can be changed as needed.
                persistentVolumeClaim:
                  claimName: pvc-sfs    # PVC name.
    2. Run the following command to create a workload that the SFS volume is mounted to:
      kubectl apply -f web-demo.yaml

      After the workload is created, the data in the container mount directory will be persistently stored. Verify the storage by referring to Verifying Data Persistence and Sharing.

Verifying Data Persistence and Sharing

  1. View the deployed application and files.

    1. Run the following command to view the pod:
      kubectl get pod | grep web-demo
      Expected output:
      web-demo-846b489584-mjhm9   1/1     Running   0             46s
      web-demo-846b489584-wvv5s   1/1     Running   0             46s
    2. Run the following commands in sequence to view the files in the /data path of the pods:
      kubectl exec web-demo-846b489584-mjhm9 -- ls /data
      kubectl exec web-demo-846b489584-wvv5s -- ls /data

      If no result is returned for both pods, no file exists in the /data path.

  2. Run the following command to create a file named static in the /data path:

    kubectl exec web-demo-846b489584-mjhm9 --  touch /data/static

  3. Run the following command to view the created file in the /data path:

    kubectl exec web-demo-846b489584-mjhm9 -- ls /data

    Expected output:

    static

  4. Verify data persistence.

    1. Run the following command to delete the pod named web-demo-846b489584-mjhm9:
      kubectl delete pod web-demo-846b489584-mjhm9

      Expected output:

      pod "web-demo-846b489584-mjhm9" deleted

      After the deletion, the Deployment controller automatically creates a replica.

    2. Run the following command to view the pod:
      kubectl get pod | grep web-demo
      The expected output is as follows, in which web-demo-846b489584-d4d4j is the newly created pod:
      web-demo-846b489584-d4d4j   1/1     Running   0             110s
      web-demo-846b489584-wvv5s    1/1     Running   0             7m50s
    3. Run the following command to check whether the file in the /data path of the new pod has been modified:
      kubectl exec web-demo-846b489584-d4d4j -- ls /data

      Expected output:

      static

      The static file is retained, indicating that the data can be stored persistently.

  5. Verify data sharing.

    1. Run the following command to view the pod:
      kubectl get pod | grep web-demo
      Expected output:
      web-demo-846b489584-d4d4j   1/1     Running   0             7m
      web-demo-846b489584-wvv5s   1/1     Running   0             13m
    2. Run the following command to create a file named share in the /data path of either pod: In this example, select the pod named web-demo-846b489584-d4d4j.
      kubectl exec web-demo-846b489584-d4d4j --  touch /data/share
      Check the files in the /data path of the pod.
      kubectl exec web-demo-846b489584-d4d4j -- ls /data

      Expected output:

      share
      static
    3. Check whether the share file exists in the /data path of another pod (web-demo-846b489584-wvv5s) as well to verify data sharing.
      kubectl exec web-demo-846b489584-wvv5s -- ls /data

      Expected output:

      share
      static

      After you create a file in the /data path of a pod, if the file is also created in the /data path of the other pod, the two pods share the same volume.

Related Operations

You can also perform the operations described in Table 4.
Table 4 Related operations

Operation

Description

Procedure

Creating a storage volume (PV)

Create a PV on the CCE console.

  1. In the navigation pane on the left, choose Storage. Then click the PVs tab. In the upper right corner, click Create PersistentVolume. In the displayed dialog box, configure the parameters.
    • Volume Type: Select SFS.
    • SFS: Click Select SFS. On the displayed page, select the SFS file system that meets your requirements and click OK.
    • PV Name: Enter the PV name, which must be unique in the same cluster.
    • Access Mode: Only ReadWriteMany is available. A storage volume can be mounted to multiple pods in read/write mode. For details, see Volume Access Modes.
    • Reclaim Policy: There are two options: Retain and Delete. For details, see PV Reclaim Policy
      NOTE:

      If multiple PVs use the same underlying storage volume, use Retain to prevent the underlying volume from being deleted with a PV.

    • Mount Options: Enter the mounting parameter key-value pairs. For details, see Configuring SFS Volume Mount Options.
  2. Click Create.

Viewing events

You can view event names, event types, number of occurrences, Kubernetes events, first occurrence time, and last occurrence time of the PVC or PV.

  1. In the navigation pane on the left, choose Storage. Then click the PVCs or PVs tab.
  2. Locate the target PVC or PV, click View Events in the Operation column to view events generated within one hour (events are retained for one hour).

Viewing a YAML file

You can view, copy, and download the YAML files of a PVC or PV.

  1. In the navigation pane on the left, choose Storage. Then click the PVCs or PVs tab.
  2. Locate the target PVC or PV, click View YAML in the Operation column to view or download the YAML.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback