CCE allows you to specify a StorageClass to automatically create an EVS disk and the corresponding PV. This function is applicable when no underlying storage volume is available.
For clusters of v1.19.10 and later, if an HPA policy is used to scale out a workload with EVS volumes mounted, a new pod cannot be started because EVS disks cannot be attached.
Parameter |
Description |
---|---|
PVC Type |
In this example, select EVS. |
PVC Name |
Enter the PVC name, which must be unique in the same namespace. |
Creation Method |
In this example, select Dynamically provision. |
Storage Classes |
The storage class for EVS disks is csi-disk. |
AZ |
Select the AZ of the EVS disk. The AZ must be the same as that of the cluster node. NOTE:
An EVS disk can only be mounted to a node in the same AZ. After an EVS disk is created, its AZ cannot be changed. |
Disk Type |
Select an EVS disk type. EVS disk types vary depending on regions. Obtain the available EVS types on the console. |
Access Mode |
EVS disks support only ReadWriteOnce, indicating that a storage volume can be mounted to one node in read/write mode. For details, see Volume Access Modes. |
Capacity (GiB) |
Capacity of the requested storage volume. |
Encryption |
Configure whether to encrypt underlying storage. If you select Enabled (key), an encryption key must be configured. Before using encryption, check whether the region where the EVS disk is located supports disk encryption. |
Resource Tag |
You can add resource tags to classify resources, which is supported only when the Everest version in the cluster is 2.1.39 or later. You can create predefined tags on the TMS console. The predefined tags are available to all resources that support tags. You can use predefined tags to improve the tag creation and resource migration efficiency. CCE automatically creates system tags CCE-Cluster-ID={Cluster ID}, CCE-Cluster-Name={Cluster name}, and CCE-Namespace={Namespace name}. These tags cannot be modified. NOTE:
After a dynamic PV of the EVS type is created, the resource tags cannot be updated on the CCE console. To update these resource tags, go to the EVS console. |
You can choose Storage in the navigation pane and view the created PVC and PV on the PVCs and PVs tab pages, respectively.
Parameter |
Description |
---|---|
PVC |
Select an existing EVS volume. An EVS volume cannot be repeatedly mounted to multiple workloads. |
Mount Path |
Enter a mount path, for example, /tmp. This parameter indicates the container path to which a data volume will be mounted. Do not mount the volume to a system directory such as / or /var/run. Otherwise, containers will be malfunctional. Mount the volume to an empty directory. If the directory is not empty, ensure that there are no files that affect container startup. Otherwise, the files will be replaced, causing container startup failures or workload creation failures.
NOTICE:
If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host machine may be damaged. |
Subpath |
Enter the subpath of the storage volume and mount a path in the storage volume to the container. In this way, different folders of the same storage volume can be used in a single pod. tmp, for example, indicates that data in the mount path of the container is stored in the tmp folder of the storage volume. If this parameter is left blank, the root path is used by default. |
Permission |
|
In this example, the disk is mounted to the /data path of the container. The container data generated in this path is stored in the EVS disk.
A non-shared EVS disk cannot be attached to multiple pods in a workload. Otherwise, the pods cannot start properly. Ensure that the number of workload pods is 1 when you attach an EVS disk.
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.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-evs-auto namespace: default annotations: everest.io/disk-volume-type: SAS # EVS disk type. everest.io/crypt-key-id: <your_key_id> # (Optional) Encryption key ID. Mandatory for an encrypted disk. everest.io/disk-volume-tags: '{"key1":"value1","key2":"value2"}' # (Optional) Custom resource tags csi.storage.k8s.io/fstype: xfs # (Optional) Set the file system type to xfs. If it is left blank, ext4 is used by default. labels: failure-domain.beta.kubernetes.io/region: <your_region> # Region of the node where the application is to be deployed. failure-domain.beta.kubernetes.io/zone: <your_zone> # AZ of the node where the application is to be deployed. spec: accessModes: - ReadWriteOnce # The value must be ReadWriteOnce for EVS disks. resources: requests: storage: 10Gi # EVS disk capacity, ranging from 1 to 32768. storageClassName: csi-disk # The storage class is EVS.
Parameter |
Mandatory |
Description |
---|---|---|
failure-domain.beta.kubernetes.io/region |
Yes |
Region where the cluster is located. For details about the value of region, see Regions and Endpoints. |
failure-domain.beta.kubernetes.io/zone |
Yes |
AZ where the EVS volume is created. It must be the same as the AZ planned for the workload. For details about the value of zone, see Regions and Endpoints. |
everest.io/disk-volume-type |
Yes |
EVS disk type. All letters are in uppercase.
|
everest.io/crypt-key-id |
No |
This parameter is mandatory when an EVS disk is encrypted. Enter the encryption key ID selected during EVS disk creation. You can use a custom key or the default key named evs/default. To obtain a key ID, log in to the DEW console, locate the key to be encrypted, and copy the key ID. |
everest.io/disk-volume-tags |
No |
This field is optional. It is supported when the Everest version in the cluster is 2.1.39 or later. You can add resource tags to classify resources. You can create predefined tags on the TMS console. The predefined tags are available to all resources that support tags. You can use predefined tags to improve the tag creation and resource migration efficiency. CCE automatically creates system tags CCE-Cluster-ID={Cluster ID}, CCE-Cluster-Name={Cluster name}, and CCE-Namespace={Namespace name}. These tags cannot be modified. |
csi.storage.k8s.io/fstype |
No |
This field is optional. It specifies the file system type. The default value is ext4. The value can be ext4 or xfs. The restrictions on using xfs are as follows:
|
storage |
Yes |
Requested PVC capacity, in Gi. The value ranges from 1 to 32768. |
storageClassName |
Yes |
The storage class for EVS disks is csi-disk. |
kubectl apply -f pvc-evs-auto.yaml
apiVersion: apps/v1 kind: StatefulSet metadata: name: web-evs-auto namespace: default spec: replicas: 1 selector: matchLabels: app: web-evs-auto serviceName: web-evs-auto # Headless Service name. template: metadata: labels: app: web-evs-auto spec: containers: - name: container-1 image: nginx:latest volumeMounts: - name: pvc-disk # 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-disk # Volume name, which can be customized. persistentVolumeClaim: claimName: pvc-evs-auto # Name of the created PVC. --- apiVersion: v1 kind: Service metadata: name: web-evs-auto # Headless Service name. namespace: default labels: app: web-evs-auto spec: selector: app: web-evs-auto clusterIP: None ports: - name: web-evs-auto targetPort: 80 nodePort: 0 port: 80 protocol: TCP type: ClusterIP
kubectl apply -f web-evs-auto.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.
kubectl get pod | grep web-evs-auto
web-evs-auto-0 1/1 Running 0 38s
kubectl exec web-evs-auto-0 -- df | grep data
Expected output:
/dev/sdc 10255636 36888 10202364 0% /data
kubectl exec web-evs-auto-0 -- ls /data
Expected output:
lost+found
kubectl exec web-evs-auto-0 -- touch /data/static
kubectl exec web-evs-auto-0 -- ls /data
Expected output:
lost+found static
kubectl delete pod web-evs-auto-0
Expected output:
pod "web-evs-auto-0" deleted
kubectl exec web-evs-auto-0 -- ls /data
Expected output:
lost+found static
If the static file still exists, the data in the EVS volume can be stored persistently.
Operation |
Description |
Procedure |
---|---|---|
Expanding the capacity of an EVS disk |
Quickly expand the capacity of a mounted EVS disk on the CCE console. |
|
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. |
|
Viewing a YAML file |
You can view, copy, and download the YAML files of a PVC or PV. |
|