Skip to main content
Version: release-0.9

Delete a MongoDB cluster

Termination policy

note

The termination policy determines how a cluster is deleted. Set the policy when creating a cluster.

terminationPolicyDeleting Operation
DoNotTerminateDoNotTerminate blocks delete operation.
HaltHalt deletes workload resources such as statefulset, deployment workloads but keep PVCs.
DeleteDelete deletes workload resources and PVCs but keep backups.
WipeOutWipeOut deletes workload resources, PVCs and all relevant resources included backups.

To check the termination policy, execute the following command.

kubectl -n demo get cluster mycluster 
>
NAME CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS AGE
mycluster mongodb mongodb-5.0 Delete Running 17m

Steps

Run the command below to delete the cluster.

kubectl delete -n demo cluster mycluster

If you want to delete a cluster and its all related resources, you can set the termination policy to WipeOut, and then delete the cluster.

kubectl patch -n demo cluster mycluster -p '{"spec":{"terminationPolicy":"WipeOut"}}' --type="merge"

kubectl delete -n demo cluster mycluster