Help Center/ Cloud Container Engine/ User Guide/ Storage/ Customizing a StorageClass
Updated on 2025-09-05 GMT+08:00

Customizing a StorageClass

StorageClasses are resource objects that define storage types in Kubernetes. They enable dynamic provisioning of storage volumes. Once you modify the parameter settings of a StorageClass, it can automatically provision and adjust storage resources based on service requirements. When you specify a StorageClass name (StorageClassName) in a PVC, Kubernetes will automatically provision a PV and the underlying storage resources based on the requirements declared in the PVC. If no matching PV is found in the cluster, Kubernetes will call the target provisioner specified in the StorageClass to create a new PV and storage resources. This simplifies the process of manually creating and maintaining PVs. The StorageClass defines default parameters for storage provisioning. If there are conflicts between the StorageClass settings and the PVC settings, the PVC settings will take precedence.

If CCE's default StorageClasses (listed in Table 3) do not meet your service needs, you can customize StorageClasses by setting parameters such as reclaim policies and binding modes.

Prerequisites

CCE Container Storage (Everest) is installed and running. For details, see CCE Container Storage (Everest).

Creating a StorageClass

CCE allows you to create a StorageClass via the console or kubectl. kubectl provides additional parameters for enhanced flexibility. Choose a method that best suits your needs.

  1. Log in to the CCE console and click the cluster name to access the cluster console.
  2. Choose Storage in the navigation pane. In the right pane, click the Storage Classes tab. Click Create Storage Class in the upper right corner. In the dialog box displayed, configure parameters.

    Figure 1 Create StorageClass

    Parameter

    Description

    Type

    The type of the underlying storage.

    Name

    The StorageClass name. The name of a StorageClass must be unique within a cluster.

    Reclaim Policy

    The policy for reclaiming the underlying storage when the PVC is deleted. For details, see PV Reclaim Policy.

    • Delete: When a PVC is deleted, its associated underlying storage resources are deleted and the PV resources are removed. Exercise caution if you select this option.
    • Retain: When a PVC is deleted, the associated PV and underlying storage resources are retained and need to be manually deleted.

    Binding

    When a PV is dynamically created, either immediately or with a delay.

    • Immediate: When a PVC is created, the storage resources and PV are created and bound to the PVC immediately, without delay. Local PVs do not support Immediate.
    • WaitForFirstConsumer: When a PVC is created, it is not immediately bound to a PV. Instead, the storage resources and PV are created and bound to the PVC only after the pod that requires the PVC is scheduled. OBS, SFS, and SFS Turbo do not support WaitForFirstConsumer.

  3. Click Create. On the Storage Classes tab page, view the created StorageClass and its information.

This section provides several StorageClass templates. You can choose the one that best suits your needs to quickly create a StorageClass resource.

Applications of Custom StorageClasses

The following provides typical applications of custom StorageClasses:

  • Meeting customized requirements and simplifying batch operations: You can customize parameters such as reclaimPolicy and volumeBindingMode to flexibly meet diverse service needs. This avoids the need for repeated parameter configuration when batch-creating PVCs, thereby simplifying the operation process and improving management efficiency.
  • Supporting smooth migration and reducing modification costs: When migrating from a custom-built Kubernetes cluster or Kubernetes services of another cloud vendor to CCE, you can create a StorageClass with the same name as that in the original environment. This allows the storageClassName in the YAML file or Helm chart to remain unchanged, effectively avoiding the operational burden and error risks associated with manually modifying a large number of configurations. For example, if the StorageClass used before the migration is named disk-standard, you can copy the YAML file of the StorageClass csi-disk, change its name to disk-standard, and create the StorageClass again.
  • Setting the default StorageClass: When creating a StorageClass, you can set it as the default by using metadata.annotations.storageclass.kubernetes.io/is-default-class. After the setting, you do not need to explicitly specify storageClassName when creating a PVC. CCE will automatically use the default StorageClass, simplifying resource declaration.
  • Associating a StorageClass with an enterprise project for unified resource management: When creating a StorageClass, you can associate it with an enterprise project by specifying parameters.everest.io/enterprise-project-id. This links the underlying storage resources to the enterprise project, facilitating subsequent resource classification management and cost accounting.

Helpful Links

Before using a new StorageClass, you only need to specify it in the storageClassName field of the target PVC. The parameter settings of the StorageClass will be used by default. If there are conflicts between the StorageClass settings and those specified in the PVC, the PVC's settings will take precedence.

To simplify the manual creation and maintenance of PVs, see the following resources: