github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-postgresql/cluster-management/start-stop-a-cluster.md (about) 1 --- 2 title: Stop/Start a PostgreSQL cluster 3 description: How to start/stop a PostgreSQL cluster 4 keywords: [postgresql, stop a cluster, start a cluster] 5 sidebar_position: 5 6 sidebar_label: Stop/Start 7 --- 8 9 # Stop/Start PostgreSQL Cluster 10 11 You can stop/start a cluster to save computing resources. When a cluster is stopped, the computing resources of this cluster are released, which means the pods of Kubernetes are released, but the storage resources are reserved. Start this cluster again if you want to restore the cluster resources from the original storage by snapshots. 12 13 ## Stop a cluster 14 15 ### Option 1. (Recommended) Use kbcli 16 17 Configure the name of your cluster and run the command below to stop this cluster. 18 19 ```bash 20 kbcli cluster stop <name> 21 ``` 22 23 ***Example*** 24 25 ```bash 26 kbcli cluster stop pg-cluster 27 ``` 28 29 ### Option 2. Create an OpsRequest 30 31 Run the command below to stop a cluster. 32 33 ```bash 34 kubectl apply -f - <<EOF 35 apiVersion: apps.kubeblocks.io/v1alpha1 36 kind: OpsRequest 37 metadata: 38 name: pg-cluster 39 generateName: stop- 40 spec: 41 # cluster ref 42 clusterRef: pg-cluster 43 type: Stop 44 EOF 45 ``` 46 47 ### Option 3. Change the YAML file of the cluster 48 49 Configure replicas as 0 to delete pods. 50 51 ```yaml 52 apiVersion: apps.kubeblocks.io/v1alpha1 53 kind: Cluster 54 metadata: 55 name: pg-cluster 56 spec: 57 clusterDefinitionRef: postgresql 58 clusterVersionRef: postgresql-14.7.0 59 terminationPolicy: WipeOut 60 componentSpecs: 61 - name: pg-replication 62 componentDefRef: postgresql 63 monitor: false 64 replicas: 0 65 volumeClaimTemplates: 66 - name: data 67 spec: 68 storageClassName: standard 69 accessModes: 70 - ReadWriteOnce 71 resources: 72 requests: 73 storage: 1Gi 74 ``` 75 76 ## Start a cluster 77 78 ### Option 1. (Recommended) Use kbcli 79 80 Configure the name of your cluster and run the command below to start this cluster. 81 82 ```bash 83 kbcli cluster start <name> 84 ``` 85 86 ***Example*** 87 88 ```bash 89 kbcli cluster start pg-cluster 90 ``` 91 92 ### Option 2. Create an OpsRequest 93 94 Run the command below to start a cluster. 95 96 ```bash 97 kubectl apply -f - <<EOF 98 apiVersion: apps.kubeblocks.io/v1alpha1 99 kind: OpsRequest 100 metadata: 101 name: pg-cluster 102 generateName: start- 103 spec: 104 # cluster ref 105 clusterRef: pg-cluster 106 type: Start 107 EOF 108 ``` 109 110 ### Option 3. Change the YAML file of the cluster 111 112 Change replicas back to the original amount to start this cluster again. 113 114 ```yaml 115 apiVersion: apps.kubeblocks.io/v1alpha1 116 kind: Cluster 117 metadata: 118 name: pg-cluster 119 spec: 120 clusterDefinitionRef: postgresql 121 clusterVersionRef: postgresql-14.7.0 122 terminationPolicy: WipeOut 123 componentSpecs: 124 - name: pg-replication 125 componentDefRef: postgresql 126 monitor: false 127 replicas: 1 128 volumeClaimTemplates: 129 - name: data 130 spec: 131 storageClassName: standard 132 accessModes: 133 - ReadWriteOnce 134 resources: 135 requests: 136 storage: 1Gi 137 ```