KubeBlocks
BlogsKubeBlocks Cloud
⌘K
​
Overview
Quickstart

Operations

Lifecycle Management
Vertical Scaling
Horizontal Scaling
Volume Expansion
Manage Elasticsearch Services
Decommission Elasticsearch Replica

Monitoring

Observability for Elasticsearch Clusters

tpl

  1. Prerequisites
    1. Check the Storage Class for Volume Expansion Support
  2. Deploy a Elasticsearch Cluster with StorageClass
  3. Verifying the Deployment
  4. Expand volume
  5. Verification
  6. Cleanup
  7. Summary

Expanding Volume in a Elasticsearch Cluster

This guide explains how to expand Persistent Volume Claims (PVCs) in a Elasticsearch cluster managed by KubeBlocks. Volume expansion enables dynamic storage capacity increases, allowing your database to scale seamlessly as data grows. When supported by the underlying storage class, this operation can be performed without downtime.

Volume expansion allows you to increase the size of a Persistent Volume Claim (PVC) after it has been created. This feature was introduced in Kubernetes v1.11 and became generally available (GA) in Kubernetes v1.24.

Prerequisites

    Before proceeding, ensure the following:

    • Environment Setup:
      • A Kubernetes cluster is up and running.
      • The kubectl CLI tool is configured to communicate with your cluster.
      • KubeBlocks CLI and KubeBlocks Operator are installed. Follow the installation instructions here.
    • Namespace Preparation: To keep resources isolated, create a dedicated namespace for this tutorial:
    kubectl create ns demo
    namespace/demo created
    

    Check the Storage Class for Volume Expansion Support

    List all available storage classes and verify if volume expansion is supported by checking the ALLOWVOLUMEEXPANSION field:

    kubectl get storageclass
    

    Example Output:

    NAME                PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
    gp2                 kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer   false                  4d10h
    kb-default-sc       ebs.csi.aws.com         Delete          WaitForFirstConsumer   true                   3d7h
    sc-s3-repo-2qsxfh   ru.yandex.s3.csi        Retain          Immediate              false                  3d7h
    

    Ensure the storage class you are using has ALLOWVOLUMEEXPANSION set to true. If it is false, the storage class does not support volume expansion.

    Deploy a Elasticsearch Cluster with StorageClass

    KubeBlocks uses a declarative approach to manage Elasticsearch clusters. Below is an example configuration for deploying a Elasticsearch cluster with 3 replicas.

    Apply the following YAML configuration to deploy the cluster:

    apiVersion: apps.kubeblocks.io/v1
    kind: Cluster
    metadata:
      name: es-multinode
      namespace: demo
    spec:
      terminationPolicy: Delete
      componentSpecs:
        - name: dit
          componentDef: elasticsearch-8
          serviceVersion: 8.8.2
          configs:
            - name: es-cm
              variables:
                # use key `roles` to specify roles this component assume
                roles: data,ingest,transform
          replicas: 3
          disableExporter: false
          resources:
            limits:
              cpu: "1"
              memory: "2Gi"
            requests:
              cpu: "1"
              memory: "2Gi"
          volumeClaimTemplates:
            - name: data
              spec:
                # specify storage class name supports Volume Expansion
                storageClassName: <STORAGE_CLASS_NAME>
                accessModes:
                  - ReadWriteOnce
                resources:
                  requests:
                    storage: 20Gi
        - name: master
          componentDef: elasticsearch-8
          serviceVersion: 8.8.2
          configs:
            - name: es-cm
              variables:
                # use key `roles` to specify roles this component assume
                roles: master
          replicas: 3
          disableExporter: false
          resources:
            limits:
              cpu: "1"
              memory: "2Gi"
            requests:
              cpu: "1"
              memory: "2Gi"
          volumeClaimTemplates:
            - name: data
              spec:
                # specify storage class name supports Volume Expansion
                storageClassName: <STORAGE_CLASS_NAME>
                accessModes:
                  - ReadWriteOnce
                resources:
                  requests:
                    storage: 20Gi
    

    Explanation of Key Fields

    • storageClassName: Specifies StorageClass name that supports volume expansion. If not set, the StorageClass annotated default will be used.
    NOTE

    ALLOWVOLUMEEXPANSION

    Ensure the storage class supports volume expansion (check ALLOWVOLUMEEXPANSION) when creating cluster.

    Verifying the Deployment

      Monitor the cluster status until it transitions to the Running state:

      kubectl get cluster es-multinode -n demo -w
      

      Expected Output:

      NAME           CLUSTER-DEFINITION   TERMINATION-POLICY   STATUS     AGE
      es-multinode                        Delete               Creating   10s
      es-multinode                        Delete               Updating   41s
      es-multinode                        Delete               Running    42s
      

      Check the pod status and roles:

      kubectl get pods -l app.kubernetes.io/instance=es-multinode -n demo
      

      Expected Output:

      NAME                    READY   STATUS    RESTARTS   AGE
      es-multinode-dit-0      3/3     Running   0          6m21s
      es-multinode-dit-1      3/3     Running   0          6m21s
      es-multinode-dit-2      3/3     Running   0          6m21s
      es-multinode-master-0   3/3     Running   0          6m21s
      es-multinode-master-1   3/3     Running   0          6m21s
      es-multinode-master-2   3/3     Running   0          6m21s
      

      Once the cluster status becomes Running, your Elasticsearch cluster is ready for use.

      TIP

      If you are creating the cluster for the very first time, it may take some time to pull images before running.

      Expand volume

      NOTE
      1. Ensure the storage class supports volume expansion (check ALLOWVOLUMEEXPANSION).
      2. The new size must be larger than the current size.
      3. Volume expansion may require additional configurations depending on the storage provider.

      You can expand the volume in one of two ways:

      Option 1: Using VolumeExpansion OpsRequest

      Apply the following YAML to increase the volume size for the elasticsearch component:

      apiVersion: operations.kubeblocks.io/v1alpha1
      kind: OpsRequest
      metadata:
        name: es-multinode-expand-volume-ops
        namespace: demo
      spec:
        clusterName: es-multinode
        type: VolumeExpansion
        volumeExpansion:
        - componentName: dit
          volumeClaimTemplates:
          - name: data
            storage: 30Gi
      

      Monitor the expansion progress with:

      kubectl describe ops es-multinode-expand-volume-ops -n demo
      

      Expected Result:

      Status:
        Phase:            Succeed
      

      Once completed, the PVC size will be updated.

      NOTE

      If the storage class you use does not support volume expansion, this OpsRequest fails fast with information like: storageClass: [STORAGE_CLASS_NAME] of volumeClaimTemplate: [VOLUME_NAME]] not support volume expansion in component [COMPONENT_NAME]

      Option 2: Direct Cluster API Update

      Alternatively, you may update the spec.componentSpecs.volumeClaimTemplates.spec.resources.requests.storage field to the desired size.

      componentSpecs:
        - name: dit
          volumeClaimTemplates:
            - name: data
              spec:
                storageClassName: <STORAGE_CLASS_NAME>
                accessModes:
                  - ReadWriteOnce
                resources:
                  requests:
                    # specify new size, and make sure it is larger than current size
                    storage: 30Gi
      

      KubeBlocks will automatically update the PVC size based on the new specifications.

      Verification

      Verify the updated cluster configuration:

      kbcli cluster describe es-multinode -n demo
      

      Expected Output:

      Resources Allocation:
      COMPONENT         INSTANCE-TEMPLATE     CPU(REQUEST/LIMIT)   MEMORY(REQUEST/LIMIT)   STORAGE-SIZE   STORAGE-CLASS
      dit                                     1 / 1                1Gi / 1Gi               data:30Gi      <STORAGE_CLASS_NAME>
      

      The volume size for the data PVC has been updated to the specified value (e.g., 30Gi in this case).

      Confirm PVC resizing completion:

      kubectl get pvc -l app.kubernetes.io/instance=es-multinode,apps.kubeblocks.io/component-name=dit -n demo
      

      Expected Output:

      NAME                      STATUS   VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS
      data-es-multinode-dit-0   Bound    pvc-uuid   30Gi       RWO            <STORAGE_CLASS_NAME>
      data-es-multinode-dit-1   Bound    pvc-uuid   30Gi       RWO            <STORAGE_CLASS_NAME>
      data-es-multinode-dit-2   Bound    pvc-uuid   30Gi       RWO            <STORAGE_CLASS_NAME>
      

      Cleanup

      To remove all created resources, delete the Elasticsearch cluster along with its namespace:

      kubectl delete cluster es-multinode -n demo
      kubectl delete ns demo
      

      Summary

      In this guide you learned how to:

      1. Verify storage class compatibility for volume expansion.
      2. Perform volume expansion using either:
        • OpsRequest for dynamic updates.
        • Cluster API for manual updates.
      3. Verify the updated PVC size and ensure the resize operation is complete.

      With volume expansion, you can efficiently scale your Elasticsearch cluster's storage capacity without service interruptions, ensuring your database can grow alongside your application needs.

      © 2025 ApeCloud PTE. Ltd.