github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-redis/cluster-management/expand-volume.md (about)

     1  ---
     2  title: Expand volume
     3  description: How to expand the volume of a Redis cluster
     4  keywords: [redis, expand volume]
     5  sidebar_position: 3
     6  sidebar_label: Expand volume
     7  ---
     8  
     9  # Expand volume
    10  
    11  You can expand the storage volume size of each pod.
    12  
    13  :::note
    14  
    15  Volume expansion triggers a concurrent restart and the leader pod may change after the operation.
    16  
    17  :::
    18  
    19  ## Before you start
    20  
    21  Check whether the cluster STATUS is `Running`. Otherwise, the following operations may fail.
    22  
    23  ```bash
    24  kbcli cluster list <name>
    25  ```
    26  
    27  ***Example***
    28  
    29  ```bash
    30  kbcli cluster list redis-cluster
    31  >
    32  NAME                 NAMESPACE        CLUSTER-DEFINITION        VERSION                TERMINATION-POLICY        STATUS         CREATED-TIME
    33  redis-cluster        default          redis                     redis-7.0.6            Delete                    Running        Apr 10,2023 19:00 UTC+0800
    34  ```
    35  
    36  ## Steps
    37  
    38  1. Change configuration. There are 3 ways to apply volume expansion.
    39  
    40     **Option 1**. (**Recommended**) Use kbcli
    41  
    42     Configure the values of `--components`, `--volume-claim-templates`, and `--storage`, and run the command below to expand the volume.
    43  
    44     ```bash
    45     kbcli cluster volume-expand redis-cluster --components="redis" \
    46     --volume-claim-templates="data" --storage="2Gi"
    47     ```
    48  
    49     - `--components` describes the component name for volume expansion.
    50     - `--volume-claim-templates` describes the VolumeClaimTemplate names in components.
    51     - `--storage` describes the volume storage size.
    52  
    53     **Option 2**. Create an OpsRequest
    54  
    55     Run the command below to expand the volume of a cluster.
    56  
    57     ```bash
    58     kubectl apply -f - <<EOF
    59     apiVersion: apps.kubeblocks.io/v1alpha1
    60     kind: OpsRequest
    61     metadata:
    62       name: ops-volume-expansion
    63     spec:
    64       clusterRef: redis-cluster
    65       type: VolumeExpansion
    66       volumeExpansion:
    67       - componentName: redis
    68         volumeClaimTemplates:
    69         - name: data
    70           storage: "2Gi"
    71     EOF
    72     ```
    73  
    74     **Option 3**. Change the YAML file of the cluster
    75  
    76     Change the value of `spec.componentSpecs.volumeClaimTemplates.spec.resources` in the cluster YAML file.
    77  
    78     `spec.componentSpecs.volumeClaimTemplates.spec.resources` is the storage resource information of the pod and changing this value triggers the volume expansion of a cluster.
    79  
    80     ```yaml
    81     apiVersion: apps.kubeblocks.io/v1alpha1
    82     kind: Cluster
    83     metadata:
    84       name: redis-cluster
    85       namespace: default
    86     spec:
    87       clusterDefinitionRef: redis
    88       clusterVersionRef: redis-7.0.6
    89       componentSpecs:
    90       - componentDefRef: redis
    91         name: redis
    92         replicas: 2
    93         volumeClaimTemplates:
    94         - name: data
    95           spec:
    96             accessModes:
    97             - ReadWriteOnce
    98             resources:
    99               requests:
   100                 storage: 1Gi # Change the volume storage size.
   101       terminationPolicy: Delete
   102     ```
   103  
   104  2. Validate the volume expansion.
   105  
   106     ```bash
   107     kbcli cluster list <name>
   108     ```
   109  
   110     ***Example***
   111  
   112     ```bash
   113     kbcli cluster list redis-cluster
   114     >
   115     NAME                 NAMESPACE        CLUSTER-DEFINITION        VERSION                  TERMINATION-POLICY        STATUS                 CREATED-TIME
   116     redis-cluster        default          redis                     redis-7.0.6              Delete                    VolumeExpanding        Apr 10,2023 16:27 UTC+0800
   117     ```
   118  
   119     - STATUS=VolumeExpanding: it means the volume expansion is in progress.
   120     - STATUS=Running: it means the volume expansion operation has been applied.