github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-postgresql/cluster-management/expand-volume.md (about) 1 --- 2 title: Expand volume 3 description: How to expand the volume of a PostgreSQL cluster 4 keywords: [postgresql, 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 pg-cluster 31 > 32 NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME 33 pg-cluster default postgresql postgresql-14.7.0 Delete Running Mar 3,2023 10:29 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 pg-cluster --components="pg-replication" \ 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: pg-cluster 65 type: VolumeExpansion 66 volumeExpansion: 67 - componentName: pg-replication 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.components.volumeClaimTemplates.spec.resources` in the cluster YAML file. `spec.components.volumeClaimTemplates.spec.resources` is the storage resource information of the pod and changing this value triggers the volume expansion of a cluster. 77 78 ```yaml 79 apiVersion: apps.kubeblocks.io/v1alpha1 80 kind: Cluster 81 metadata: 82 name: pg-cluster 83 namespace: default 84 spec: 85 clusterDefinitionRef: postgresql 86 clusterVersionRef: postgresql-14.7.0 87 componentSpecs: 88 - name: pg-replication 89 componentDefRef: postgresql 90 replicas: 1 91 volumeClaimTemplates: 92 - name: data 93 spec: 94 accessModes: 95 - ReadWriteOnce 96 resources: 97 requests: 98 storage: 1Gi # Change the volume storage size. 99 terminationPolicy: Halt 100 ``` 101 102 2. Validate the volume expansion. 103 104 ```bash 105 kbcli cluster list <name> 106 ``` 107 108 ***Example*** 109 110 ```bash 111 kbcli cluster list pg-cluster 112 > 113 NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME 114 pg-cluster default postgresql postgresql-14.7.0 Delete VolumeExpanding Apr 10,2023 16:27 UTC+0800 115 ``` 116 117 * STATUS=VolumeExpanding: it means the volume expansion is in progress. 118 * STATUS=Running: it means the volume expansion operation has been applied.