Skip to content

Dynamically expand persistent volumes

In a Kubernetes environment, NebulaGraph's data is stored on Persistent Volumes (PVs). Dynamic volume expansion refers to increasing the capacity of a volume without stopping the service, enabling NebulaGraph to accommodate growing data. This topic explains how to dynamically expand the PV for NebulaGraph services in a Kubernetes environment.

Note

  • After the cluster is created, you cannot dynamically increase the number of PVs while the cluster is running.
  • The method described in this topic is only for online volume expansion and does not support volume reduction.

Background

In Kubernetes, a StorageClass is a resource that defines a particular storage type. It describes a class of storage, including its provisioner, parameters, and other details. When creating a PersistentVolumeClaim (PVC) and specifying a StorageClass, Kubernetes automatically creates a corresponding PV. The principle of dynamic volume expansion is to edit the PVC and increase the volume's capacity. Kubernetes will then automatically expand the capacity of the PV associated with this PVC based on the specified storageClassName in the PVC. During this process, new PVs are not created; the size of the existing PV is changed. Only dynamic storage volumes, typically those associated with a storageClassName, support dynamic volume expansion. Additionally, the allowVolumeExpansion field in the StorageClass must be set to true. For more details, see the Kubernetes documentation on expanding Persistent Volume Claims.

In NebulaGraph Operator, you cannot directly edit PVC because Operator automatically creates PVC based on the configuration in the spec.<metad|storaged>.dataVolumeClaim of the Nebula Graph cluster. Therefore, you need to modify the cluster's configuration to update the PVC and trigger dynamic online volume expansion for the PV.

Prerequisites

  • Kubernetes version is equal to or greater than 1.18.
  • A StorageClass has been created in the Kubernetes environment. For details, see Expanding Persistent Volumes Claims.
    • Ensure the allowVolumeExpansion field in the StorageClass is set to true.
    • Make sure that the provisioner configured in the StorageClass supports dynamic expansion.
  • A NebulaGraph cluster is created in Kubernetes. For specific steps, see Create a NebulaGraph cluster.
  • NebulaGraph cluster Pods are in running status.

Online volume expansion example

In the following example, we assume that the StorageClass is named ebs-sc and the NebulaGraph cluster is named nebula. We will demonstrate how to dynamically expand the PV for the Storage service.

  1. Check the status of the Storage service Pod:

    kubectl get pod
    

    Example output:

    nebula-storaged-0                                                1/1     Running   0                43h
    
  2. Check the PVC and PV information for the Storage service:

    # View PVC 
    kubectl get pvc
    

    Example output:

    storaged-data-nebula-storaged-0   Bound    pvc-36ca3871-9265-460f-b812-7e73a718xxxx   5Gi        RWO            ebs-sc     43h
    
    # View PV and confirm that the capacity of the PV is 5Gi
    kubectl get pv
    

    Example output:

    pvc-36ca3871-9265-460f-b812-xxx   5Gi        RWO            Delete           Bound       default/storaged-data-nebula-storaged-0   ebs-sc              43h
    
  3. Assuming all the above-mentioned prerequisites are met, use the following command to request an expansion of the PV for the Storage service to 10Gi:

    kubectl patch nc nebula --type='merge' --patch '{"spec": {"storaged": {"dataVolumeClaims":[{"resources": {"requests": {"storage": "10Gi"}}, "storageClassName": "ebs-sc"}]}}}'
    

    Example output:

    nebulacluster.apps.nebula-graph.io/nebula patched
    
  4. After waiting for about a minute, check the expanded PVC and PV information:

    kubectl get pvc
    

    Example output:

    storaged-data-nebula-storaged-0   Bound    pvc-36ca3871-9265-460f-b812-7e73a718xxxx   10Gi        RWO            ebs-sc     43h
    
    kubectl get pv
    

    Example output:

    pvc-36ca3871-9265-460f-b812-xxx   10Gi        RWO            Delete           Bound       default/storaged-data-nebula-storaged-0   ebs-sc              43h
    

    As you can see, both the PVC and PV capacity have been expanded to 10Gi.


Last update: November 15, 2023