Alibaba Cloud disks are block-level storage resources for Elastic Compute Service (ECS). Alibaba Cloud disks provide low latency, high performance, high durability, and high reliability. Container Service for Kubernetes (ACK) allows you to use the Container Storage Interface (CSI) plug-in to statically and dynamically provision disk volumes. This topic describes how to mount a dynamically provisioned disk volume by using CSI and how to use the dynamically provisioned disk volume to persist data.

Prerequisites

Background information

For more information about StorageClasses, see Configure StorageClasses.

Verify that the dynamically provisioned disk volume can be used to persist data

  1. View the pod that runs the nginx-dynamic application and the files in the disk.
    1. Run the following command to query the pod that runs the nginx-dynamic application:
      kubectl get pod | grep dynamic

      Expected output:

      nginx-dynamic-xxx   1/1     Running     0          3m
    2. Run the following command to check whether a new disk is mounted to the /data path:
      kubectl exec nginx-dynamic-xxx df | grep data

      Expected output:

      /dev/vdh        20511312    45080  20449848   1% /data
    3. Run the following command to query the files in the /data path:
      kubectl exec nginx-dynamic-xxx ls /data

      Expected output:

      lost+found
  2. Create a file in the disk.
    1. Run the following command to create a file named dynamic in the /data path:
      kubectl exec nginx-dynamic-xxx touch /data/dynamic
    2. Run the following command to query the files in the /data path:
      kubectl exec nginx-dynamic-xxx ls /data

      Expected output:

      dynamic
      lost+found
  3. Run the following command to delete the pod named nginx-dynamic-xxx:
    kubectl delete pod nginx-dynamic-xxx

    Expected output:

    pod "nginx-dynamic-xxx" deleted
  4. Verify that the file still exists in the disk after the pod is deleted.
    1. Run the following command to quey the pod that is recreated:
      kubectl get pod 

      Expected output:

      NAME                               READY   STATUS      RESTARTS   AGE
      nginx-dynamic-xxx                   1/1     Running     0          2m
    2. Run the following command to query the files in the /data path:
      kubectl exec nginx-dynamic-xxx ls /data

      Expected output:

      dynamic
      lost+found
      The dynamic file still exists in the /data path. This indicates that data is persisted to the dynamically provisioned disk.