You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
NFS access methods
Using static EFS PVs via NFS
Copy page
Download PDF
Using static EFS PVs via NFS
This topic describes how to create an EFS PersistentVolume (PV) and PersistentVolumeClaim (PVC) via NFS, and how workloads use a static EFS PV.​
Prerequisites​
  • (Optional) The kubectl tool has already been installed locally, and the target cluster has been connected by using kubectl. For details, see Connecting to clusters.​
Usage limits​
  • StatefulSets require exclusive access to a volume, and do not support a manually created PVC.​
Creating through the console​
Step 1: Create a PV​
  1. Log in to the VKE console.​
  1. In the left navigation pane, click Cluster. In the right part of the page, click the target cluster name to open the management page of this cluster.​
  1. In the left navigation bar of the cluster management page, click Storage > PersistentVolume. Click Create PersistentVolume and configure parameters on the page that appears.​
  • ​
    Parameter​
    Description​
    How to create​
    Select a method for creating the PV. Currently, you can select Static creation, in which the administrator creates one.​
    Name​
    Specify a valid name for the PV. The name must be unique within the cluster.​
    StorageClass type​
    Select the storage type. In this scenario, select EFS.​
    Access type​
    Select an access type for the PV. Valid values: FSX and NFS. In this scenario, select NFS.​
    Access mode​
    Select a PV access mode. You can select ReadWriteMany, which enables read and write access by multiple nodes.​
    Project​
    Assign the PV to a project so that you can perform operations such as maintenance and authorization at the project level. By default, the default project is selected. For more details, see Project management.​
    Mount point​
    Select a mount point that exists under a created NFS file system and is in the same VPC as the cluster.​
    Subdirectory​
    Enter a valid subdirectory that complies with the on-screen rules. The default directory is the root directory, which is represented by /.​
    tip​
    Ensure that the subdirectory already exists in EFS.​
    NFS version​
    Select an NFS version for the PV. NFSv3 and NFSv4.1 are supported.​
    ​
  1. Click Confirm.​
Step 2: Create a PVC​
  1. In the left navigation bar of the cluster management page, click Storage > PersistentVolumeClaim. Click Create PersistentVolumeClaim and configure parameters on the page that appears.​
  • ​
    Parameter​
    Description​
    Namespace​
    Select the namespace to which the PVC belongs. We recommend selecting a custom namespace or the system-created default namespace. For details about namespaces, see Namespace overview.​
    Name​
    Specify a name for the PVC. The name must be unique within the cluster.​
    StorageClass type​
    Select the storage type. In this scenario, select Elastic NAS.​
    Access mode​
    Select a PVC access mode. You can select ReadWriteMany, which enables read and write access by multiple nodes.​
    Billing type​
    Select a resource billing type as needed. Currently, pay-as-you-go is supported.​
    How to create​
    Configure the method for creating a PVC. In this scenario, select Use an existing PersistentVolume.​
    PersistentVolume​
    Select the created PV for binding.​
    ​
  1. Click Confirm.​
Step 3: Create an application and mount the PV​
After the static PV of the EFS type is created, add the PV to a workload that will use the PV. Supported workloads include Deployment, StatefulSet, Job, CronJob, and DaemonSet.​
You can add a PV to a workload when creating it or updating it. For details, see Workloads.​
Creating through kubectl​
Step 1: Create a PV​
  1. Create a YAML file for the PV. The following vke-nas-static-pv.yaml file serves as an example:​
  • ​
    apiVersion: v1​
    kind: PersistentVolume​
    metadata:​
    name: vke-efs-static-pv​
    spec:​
    capacity:​
    storage: 20Gi # The PV capacity. This field is required by Kubernetes only for validation. It does not impose an actual capacity limit.​
    accessModes:​
    - ReadWriteMany # PV access mode. The only supported mode is ReadWriteMany, which allows read and write access by multiple nodes.​
    csi:​
    driver: nas.csi.volcengine.com # Driver required for storage mount.​
    volumeAttributes:​
    type: efs # The PV type, which needs to be set to efs.​
    server: cnshbe27f6ad23bd8.3qda7dut***.efs.ivolces.com # The domain of the EFS filesystem mount point.​
    path: / # The subdirectory of the file system for mounting.​
    volumeHandle: vke-efs-static-pv # The unique identifier of the PV. Keep it consistent with the PV name. To use multiple PVs simultaneously, the value for each PV must be different.​
    mountOptions:​
    - nolock,proto=tcp,noresvport​
    - vers=3 # The NFS version. Value: 3 (indicating NFSv3) or 4.1 (indicating NFSv4.1).​
    persistentVolumeReclaimPolicy: Delete # PV reclaim policy. Value: Retain or Delete.​
    volumeMode: Filesystem # The PV type. Value: Filesystem (using the volume as a filesystem. It will be mounted by the pod to a directory) or Block (using the volume as a block device).​
    ​
  • The key parameters are described in the following table.​
  • ​
    Parameter​
    Description​
    storage​
    Declared PV capacity. Unit: Gi. This field is required by Kubernetes. The value has no actual meaning and is only for validation. The actual capacity is subject to the created storage capacity.​
    accessModes​
    The PV access mode. Only ReadWriteMany is supported, which allows the PV to be read and written by multiple pods.​
    driver​
    The driver for mounting a PV. In this example, you need to set the value to nas.csi.volcengine.com, which indicates the csi-nas add-on.​
    type​
    The PV type. In this example, set it to efs.​
    server​
    The domain of the EFS filesystem mount point.​
    path​
    The subdirectory of the filesystem to be mounted. It defaults to the root directory ("/"). Ensure that the specified directory exists. Otherwise, the mount will fail.​
    volumeHandle​
    The unique identifier of the PV. Keep it consistent with the name of the PV.​
    mountOptions​
    Configure PV mount parameters, which support dynamic modification and only take effect on newly mounted PVs instead of those already mounted. You can use the vers parameter to specify the NFS version number for mounting the PV. Valid values:​
    • 3: Indicates NFSv3.​
    • 4.1: Indicates NFSv4.1.​
    persistentVolumeReclaimPolicy​
    The PV reclaim policy. The following information is included:​
    • Retain: The Retain policy. When the PVC bound to the PV is deleted, the PV is retained.​
    • Delete: The Delete policy. When the PVC bound to the PV is deleted, the PV is deleted synchronously.​
    volumeMode​
    The PV types. Valid values:​
    • Filesystem: (Default) Use the PV as a file system. The PV will be formatted and mounted to a file system (such as ext4 and xfs), and the file system will be mounted to a specified path in the container. You can use the ls command (such as ls /data) in the container to view the mounted directories or files, and directly read and write files.​
    • Block: Use the PV as a block device. It is directly exposed to the container without being formatted or mounted to a file system. You can perform operations on the block device by using paths such as /dev/block/xxx, and applications must support read and write operations on the raw block device.​
    ​
  1. Run the following command to create the PV.​
  • ​
    kubectl create -f vke-nas-static-pv.yaml​
    ​
Step 2: Create a PVC​
  1. Create a YAML file for the PVC. The following vke-efs-static-pvc.yaml file serves as an example:​
  • ​
    apiVersion: v1​
    kind: PersistentVolumeClaim​
    metadata:​
    name: vke-efs-static-pvc # PVC name.​
    namespace: default # Namespace to which the PVC belongs.​
    spec:​
    accessModes:​
    - ReadWriteMany # PV access mode. Only ReadWriteMany is supported. ReadWriteMany allows read and write access from multiple nodes.​
    resources:​
    requests:​
    storage: 20Gi # Declared storage usage. The unit is Gi. Ensure it is consistent with the capacity of the created PV.​
    volumeMode: Filesystem # The PV type. Valid values: Filesystem (using the PV as a filesystem) and Block (using the PV as a block device). The value must be consistent with the type configured in the PV.​
    volumeName: vke-efs-static-pv # Name of the created PV.​
    ​
  • The key parameters are described in the following table.​
  • ​
    Parameter​
    Description​
    accessModes​
    The PVC access mode. You can only select ReadWriteMany, which enables read and write access by multiple nodes.​
    storage​
    The declared storage capacity. Unit: Gi. It must be consistent with the capacity of the created PV.​
    volumeMode​
    The PV type. It must be consistent with the type configured for the PV. The following information is included:​
    • Filesystem: (Default) Use the PV as a file system. The PV will be formatted and mounted to a file system (such as ext4 and xfs), and the file system will be mounted to a specified path in the container. You can use the ls command (such as ls /data) in the container to view the mounted directories or files, and directly read and write files.​
    • Block: Use the volume as a block device. It is directly exposed to the container without being formatted or mounted to a file system. You can perform operations on the block device by using paths such as /dev/block/xxx, and applications must support read and write operations on the raw block device.​
    volumeName​
    The name of the PV, which must be consistent with the name configured for the PV.​
    ​
  1. Run the following command to create the PVC.​
  • ​
    kubectl create -f vke-efs-static-pvc.yaml​
    ​
  1. Run the following command to view the static binding result of the PVC and PV.​
  • ​
    kubectl get pvc​
    ​
  • If the response is similar to the following one, the binding is successful.​
  • ​
    NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE​
    vke-efs-static-pvc Bound vke-efs-static-pv 20Gi RWX 8s ​
    ​
Step 3: Create an application and mount the PV​
  1. Create a YAML file for the Deployment. The following vke-nas-static-deployment.yaml file is an example:​
  • ​
    apiVersion: apps/v1​
    kind: Deployment​
    metadata:​
    name: vke-efs-static-deployment​
    namespace: default​
    labels:​
    app: nginx​
    spec:​
    replicas: 1​
    selector:​
    matchLabels:​
    app: vke-efs-static-deployment​
    template:​
    metadata:​
    labels:​
    app: vke-efs-static-deployment​
    spec:​
    containers:​
    - image: doc-cn-beijing.cr.volces.com/vke/nginx-demo:v1.0​
    name: nginx​
    volumeMounts:​
    - mountPath: /tmp # Mount location of the PV in the container.​
    name: nas-pv​
    volumes:​
    - name: nas-pv​
    persistentVolumeClaim:​
    claimName: vke-efs-static-pvc # The name of the created PVC.​
    ​
  1. Run the following command to create the Deployment.​
  • ​
    kubectl create -f vke-nas-static-deployment.yaml ​
    ​
Validating results​
After creating a workload and mounting a PV to it as described in the preceding steps, you can verify the volume mounting status and persistent storage via the following methods.​
  1. Run the following command to check whether the PV is mounted to the specified path in the pod.​
  • ​
    kubectl exec vke-efs-static-deployment-xxx -- df | grep tmp​
    ​
  • The expected response is as follows.​
  • ​
    cnshbe27***.3qda7dutskr***.efs.ivolces.com:/ 10995116277760 0 10995116277760 0% /tmp​
    ​
  1. Check the mount path in the pod to view the data in the PV.​
  • ​
    kubectl exec vke-nas-static-deployment-xxx -- ls /tmp​
    ​
  • The expected response is as follows.​
  • ​
    lost+found​
    ​
  1. Write a file to the PV.​
  • ​
    kubectl exec vke-nas-static-deployment-xxx -- touch /tmp/test​
    ​
  1. Delete the pod.​
  • ​
    kubectl delete pod vke-nas-static-deployment-xxx​
    ​
  1. Check the mount path of the PV in the newly created pod.​
  • ​
    kubectl exec vke-nas-static-deployment-xxx -- ls /tmp​
    ​
  • The expected result is as follows. You can see that the file written to the PV still exists and is not deleted along with the pod. This indicates that persistent storage of data is achieved.​
  • ​
    lost+found ​
    test​
    ​
Related documentation​
Last updated: 2026.07.24 10:53:34