Skip to main content
Version: v25.09

PVC Expansion Through StatefulSet Modification

Feature Overview

When the product management scale is expanded, the service instances, resource quotas, and storage resources need to be adjusted. However, the PVC template size of StatefulSets cannot be modified. You need to manually adjust the PVC size during capacity expansion, which is time-consuming. This feature allows you to enable automatic expansion of the PVC capacity by modifying the PVC template size of StatefulSets.

Application Scenarios

When the product management scale is expanded, the service instances, resource quotas, and storage resources need to be adjusted. In this case, you can modify the StatefulSet template to expand the capacity.

Supported Capabilities

There are StatefulSet resources configured with PVCs in the cluster, and the SC feature is enabled.

Highlights

You can modify the PVC template size of StatefulSets to enable automatic expansion of the capacity of PVCs.

Implementation Principles

  • The feature gate HWStatefulSetVolumeExpansion is added, which needs to be enabled for both kube-apiserver and kube-controller-manager and is used to enable the capability of modifying StatefulSets to expand the capacity of PVCs.

  • The existing feature supports resource storage by modifying PVC capacity. Currently, only the PVC size change declared in the StatefulSet controller is monitored and the PVC storage size is dynamically modified to dynamically expand storage resources.

  • The StatefulSet controller listens to PVC update events to update the StatefulSet status.

  • The extended fields are added to a StatefulSet to indicate the modification status of volumeClaimTemplates.

      status: 
    availableReplicas: 3
    currentReplicas: 3
    currentRevision: ex1-54c5bd476c
    readyReplicas: 3
    replicas: 3
    updatedReplicas: 3
    volumeClaimTemplates:
    - finishedReconciliationGeneration: 2
    readyReplicas: 1
    templateName: vol1

None

Installation

No installation is required.

Using PVCs for Capacity Expansion

Prerequisites

None

Context

None

Constraints

None

Procedure

To use this feature, you need to enable the allowVolumeExpansion function of the local CSI and modify the PVC definition to implement automatic capacity expansion.

  1. Check whether the feature is enabled.

    kubectl get sc -A

    1.1 Check whether allowVolumeExpansion of the local CSI is set to true.

    1.2 If the value of allowVolumeExpansion is false, run the following command to enable the function:

    kubectl edit sc <sc_name>
  2. Query all StatefulSets.

    kubectl get sts -A
  3. Modify the target StatefulSet and modify the PVC size configuration.

    kubectl edit sts -n <namespace> <sts_name>

Find the part where the PVC is defined and change the storage size. The format is as follows:

  volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
# ...
spec:
# ...
resource:
requests:
storage: 30Gi # Change the value.
# ...
# ...