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

Volcengine Kubernetes Engine

Copy page
Download PDF
EBS volume snapshots
Using EBS snapshots
Copy page
Download PDF
Using EBS snapshots
This topic describes how to statically and dynamically create Elastic Block Storage (EBS) snapshots.​
tip​
[Beta · Apply for Trial]: The EBS snapshot feature is currently in the beta stage. We recommend that you test this feature in non-production environments first and exercise caution when using it in production.​
Limits​
EBS snapshots support the instant availability feature. After enabling this feature, you do not need to wait for the snapshot creation progress to reach 100% before using the snapshot to create a new EBS volume. This feature provides a faster and more convenient snapshot service. For details, see Instant snapshot availability.​
The following limitations apply to the instant availability feature:​
  1. Instant availability supports only ESSD_PL0 and ESSD_FlexPL EBS types.​
  1. The available traffic bandwidth during lazy loading is limited to 15-40 MB/s per volume.​
  1. Snapshot size cannot exceed 300 GB.​
  1. During lazy loading when you use an instant snapshot to create a PersistentVolume (PV), the snapshot cannot be deleted.​
  1. A single account in a single region can have up to 10 instant snapshots in the lazy loading state.​
Prerequisites​
  • The csi-ebs add-on has been installed. For details, see csi-ebs.​
  • The snapshot-controller add-on has been installed. For details, see Installing add-ons.​
  • To use the instant snapshot availability feature, ensure that the csi-ebs add-on has been upgraded to version 1.2.13 or later.​
Dynamically creating snapshots​
Step 1: Create a VolumeSnapshotClass​
  1. Create a YAML file for the VolumeSnapshotClass. The following vke-volumesnapshotclass.yaml file serves as an example:​
  • ​
    apiVersion: snapshot.storage.k8s.io/v1​
    kind: VolumeSnapshotClass​
    metadata:​
    name: vke-volumesnapshotclass # The name of the VolumeSnapshotClass.​
    parameters:​
    instantAccess: "false" # Whether to enable the EBS instant snapshot availability feature. The valid value is false or true. By default, this feature is disabled.​
    driver: ebs.csi.volcengine.com # The driver type. This example uses ebs.csi.volcengine.com, which indicates the csi-ebs add-on.​
    deletionPolicy: Delete # Snapshot reclaim policy. Supported policies include Delete (deleting VolumeSnapshot also deletes VolumeSnapshotContent and related resources) and Retain (deleting VolumeSnapshot does not automatically delete VolumeSnapshotContent and related resources).​
    ​
  1. Run the following command to create the VolumeSnapshotClass.​
  • ​
    kubectl apply -f vke-volumesnapshotclass.yaml​
    ​
Step 2: Create a workload and write data​
Create a workload (application) and write data. This topic uses a stateless workload (Deployment) as an example.​
  1. Create a YAML file for the Deployment. The following deployment-nginx.yaml file serves as an example. For details, see Using dynamic EBS PersistentVolumes. For information about how to configure other types of workload, see Workloads.​
  • ​
    apiVersion: apps/v1​
    kind: Deployment​
    metadata:​
    name: deployment-nginx​
    spec:​
    selector:​
    matchLabels:​
    app: nginx​
    template:​
    metadata:​
    labels:​
    app: nginx​
    spec:​
    containers:​
    - name: nginx​
    image: doc-cn-beijing.cr.volces.com/vke/nginx-demo:v1.0 # The image file to deploy.​
    ports:​
    - containerPort: 80​
    name: web​
    volumeMounts:​
    - name: ebs-essd-volume0​
    mountPath: /data​
    volumes:​
    - name: ebs-essd-volume0​
    persistentVolumeClaim:​
    claimName: pvc-ebs # The name of the PVC.​
    ​
  1. Run the following command to create the workload.​
  • ​
    kubectl apply -f deployment-nginx.yaml​
    ​
  1. Write data to the pod.​
tip​
  • Replace deployment-nginx-6fcb64f6cd-qcxkt with your own pod name.​
  • ​
    kubectl exec deployment-nginx-6fcb64f6cd-qcxkt -- touch /data/test ​
    ​
  • Check whether the data has been written.​
  • ​
    kubectl exec deployment-nginx-6fcb64f6cd-qcxkt -- ls /data ​
    ​
  • The expected output is as follows:​
  • ​
    lost+found​
    test ​
    ​
Step 3: Create a snapshot​
  1. Create a VolumeSnapshot YAML file. The following vke-snapshot.yaml file serves as an example:​
  • ​
    apiVersion: snapshot.storage.k8s.io/v1​
    kind: VolumeSnapshot​
    metadata:​
    name: vke-snapshot # The custom VolumeSnapshot name, which will be used when you restore data from the snapshot.​
    namespace: default # The namespace of the VolumeSnapshot.​
    spec:​
    volumeSnapshotClassName: vke-volumesnapshotclass # The VolumeSnapshotClass created in Step 1.​
    source:​
    persistentVolumeClaimName: pvc-ebs # It must be consistent with the PVC name used by the workload in Step 2.​
    ​
  1. Run the following command to create the VolumeSnapshot.​
  • ​
    kubectl apply -f vke-snapshot.yaml​
    ​
Step 4: Validate the result​
  1. Run the following command to check whether the snapshot was created successfully.​
  • ​
    kubectl get VolumeSnapshot​
    ​
  • The expected output is as follows. You can view the status and source of the EBS snapshot.​
  • ​
    NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE​
    vke-snapshot true pvc-ebs 20Gi vke-volumesnapshotclass snapcontent-b863c082-ad70-4*** 2m29s 2m29s​
    ​
  1. Run the following command to view the details of the EBS snapshot.​
  • ​
    kubectl get VolumeSnapshotContent​
    ​
  • The expected output is as follows:​
  • ​
    NAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT VOLUMESNAPSHOTNAMESPACE AGE​
    snapcontent-b863c082-ad70-4*** true 21474836480 Delete ebs.csi.volcengine.com vke-volumesnapshotclass vke-snapshot default 3m12s​
    ​
Statically creating snapshots​
  1. In the ECS console create a snapshot. For details, see Creating snapshots.​
  1. (Optional) To use the instant snapshot feature, add the following label to the snapshot configuration.​
  • ​
    Label key​
    Label value​
    ebs.csi.volcengine.com/use-instant-access​
    true​
    ​
  1. Create a VolumeSnapshotContent YAML file. The following vke-snapshotcontent.yaml file serves as an example:​
  • ​
    apiVersion: snapshot.storage.k8s.io/v1​
    kind: VolumeSnapshotContent​
    metadata:​
    name: vke-snapshotcontent​
    spec:​
    deletionPolicy: Retain # Snapshot reclaim policy. Supported policies include Delete (deleting VolumeSnapshot also deletes VolumeSnapshotContent and related resources) and Retain (deleting VolumeSnapshot does not automatically delete VolumeSnapshotContent and related resources).​
    driver: ebs.csi.volcengine.com # The driver type. This example uses ebs.csi.volcengine.com, which indicates the csi-ebs add-on.​
    source:​
    snapshotHandle: snap-f1ksxj7k1d******** # The ID of the created snapshot in ECS.​
    volumeSnapshotRef:​
    name: vke-snapshot # The name of the VolumeSnapshot.​
    namespace: default # The namespace of the VolumeSnapshot.​
    ​
  1. Run the following command to create a VolumeSnapshotContent.​
  • ​
    kubectl apply -f vke-snapshotcontent.yaml​
    ​
  1. Create a VolumeSnapshot YAML file. The following vke-snapshot.yaml file serves as an example:​
  • ​
    apiVersion: snapshot.storage.k8s.io/v1​
    kind: VolumeSnapshot​
    metadata:​
    name: vke-snapshot # The name of the VolumeSnapshot. The name must be consistent with the custom snapshot name specified in Step 2. This name will be used for restoring data from the snapshot.​
    namespace: default # The namespace of the VolumeSnapshot. It must be consistent with the namespace selected in Step 2.​
    spec:​
    source:​
    volumeSnapshotContentName: vke-snapshotcontent # The name of the VolumeSnapshotContent created in Step 2.​
    ​
  1. Run the following command to create the VolumeSnapshot.​
  • ​
    kubectl apply -f vke-snapshot.yaml​
    ​
Restoring data from snapshots​
After a snapshot is created, you can restore data from the snapshot to a new PVC. The following YAML file serves as an example. For details, see Using EBS as dynamic PersistentVolumes.​
​
apiVersion: v1​
kind: PersistentVolumeClaim​
metadata:​
name: restore-test​
namespace: default​
spec:​
storageClassName: ebs-ssd​
dataSource:​
name: vke-snapshot # The name of the snapshot from which you want to restore data. It is the name that you specified when you created the VolumeSnapshot. Make sure that you specify the name of the target snapshot.​
kind: VolumeSnapshot​
apiGroup: snapshot.storage.k8s.io​
accessModes:​
- ReadWriteOnce​
resources:​
requests:​
storage: 20Gi # The storage needs to be greater than or equal to the size of the snapshot (original EBS volume)​
​
​
Last updated: 2026.08.19 17:44:49