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