github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-postgresql/cluster-management/delete-a-postgresql-cluster.md (about) 1 --- 2 title: Delete a PostgreSQL Cluster 3 description: How to delete a PostgreSQL Cluster 4 keywords: [postgresql, delete a cluster] 5 sidebar_position: 7 6 sidebar_label: Delete protection 7 --- 8 9 import Tabs from '@theme/Tabs'; 10 import TabItem from '@theme/TabItem'; 11 12 # Delete a PostgreSQL Cluster 13 14 :::note 15 16 The termination policy determines how a cluster is deleted. 17 18 ::: 19 20 ## Termination policy 21 22 | **terminationPolicy** | **Deleting Operation** | 23 |:----------------------|:-------------------------------------------------------------------------------------------| 24 | `DoNotTerminate` | `DoNotTerminate` blocks delete operation. | 25 | `Halt` | `Halt` deletes workload resources such as statefulset, deployment workloads but keep PVCs. | 26 | `Delete` | `Delete` deletes workload resources and PVCs but keep backups. | 27 | `WipeOut` | `WipeOut` deletes workload resources, PVCs and all relevant resources included backups. | 28 29 To check the termination policy, execute the following command. 30 31 <Tabs> 32 33 <TabItem value="kbcli" label="kbcli" default> 34 35 ```bash 36 kbcli cluster list pg-cluster 37 > 38 NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME 39 pg-cluster default postgresql postgresql-14.7.0 Delete Running Mar 03,2023 18:49 UTC+0800 40 ``` 41 42 </TabItem> 43 44 <TabItem value="kubectl" label="kubectl"> 45 46 ```bash 47 kubectl -n demo get cluster pg-cluster 48 > 49 NAME CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS AGE 50 pg-cluster postgresql postgresql-14.8.0 Delete Running 29m 51 ``` 52 53 </TabItem> 54 55 </Tabs> 56 57 ## Step 58 59 Run the command below to delete a specified cluster. 60 61 <Tabs> 62 63 <TabItem value="kbcli" label="kbcli" default> 64 65 ```bash 66 kbcli cluster delete pg-cluster 67 ``` 68 69 </TabItem> 70 71 <TabItem value="kubectl" label="kubectl"> 72 73 If you want to delete a cluster and its all related resources, you can modify the termination policy to `WipeOut`, then delete the cluster. 74 75 ```bash 76 kubectl patch -n demo cluster pg-cluster -p '{"spec":{"terminationPolicy":"WipeOut"}}' --type="merge" 77 78 kubectl delete -n demo cluster pg-cluster 79 ``` 80 81 </TabItem> 82 83 </Tabs>