Cleaning up a Cluster¶
To tear down the cluster, the following resources need to be cleaned up:
- The resources created under Rook's namespace (default
rook-ceph) such as the Rook operator created by
operator.yamland the cluster CR
/var/lib/rook/rook-ceph: Path on each host in the cluster where configuration is stored by the ceph mons and osds
- Devices used by the OSDs
If the default namespaces or paths such as
dataDirHostPath are changed in the example yaml files, these namespaces and paths will need to be changed throughout these instructions.
If tearing down a cluster frequently for development purposes, it is instead recommended to use an environment such as Minikube that can easily be reset without worrying about any of these steps.
Delete the Block and File artifacts¶
First clean up the resources from applications that consume the Rook storage.
After applications have been cleaned up, the Rook cluster can be removed. It is important to delete applications before removing the Rook operator and Ceph cluster. Otherwise, volumes may hang and nodes may require a restart.
Delete the CephCluster CRD¶
DATA WILL BE PERMANENTLY DELETED AFTER DELETING THE
- To instruct Rook to wipe the host paths and volumes, edit the
CephClusterand add the
Once the cleanup policy is enabled, any new configuration changes in the CephCluster will be blocked. Nothing will happen until the deletion of the CR is requested, so this
cleanupPolicy change can still be reverted if needed.
Checkout more details about the
- Delete the
- Verify that the cluster CR has been deleted before continuing to the next step.
cleanupPolicy was applied, wait for the
rook-ceph-cleanup jobs to be completed on all the nodes. These jobs will perform the following operations:
- Delete the namespace directory under
dataDirHostPath, for example
/var/lib/rook/rook-ceph, on all the nodes
- Wipe the data on the drives on all the nodes where OSDs were running in this cluster
The cleanup jobs might not start if the resources created on top of Rook Cluster are not deleted completely. See deleting block and file artifacts
Delete the Operator Resources¶
Remove the Rook operator, RBAC, and CRDs, and the
Delete the data on hosts¶
The final cleanup step requires deleting files on each host in the cluster. All files under the
dataDirHostPath property specified in the cluster CRD will need to be deleted. Otherwise, inconsistent state will remain when a new cluster is started.
cleanupPolicy was not added to the CephCluster CR before deleting the cluster, these manual steps are required to tear down the cluster.
Connect to each machine and delete the namespace directory under
dataDirHostPath, for example
Disks on nodes used by Rook for OSDs can be reset to a usable state. Note that these scripts are not one-size-fits-all. Please use them with discretion to ensure you are not removing data unrelated to Rook.
A single disk can usually be cleared with some or all of the steps below.
Ceph can leave LVM and device mapper data that can lock the disks, preventing the disks from being used again. These steps can help to free up old Ceph disks for re-use. Note that this only needs to be run once on each node. If you have only one Rook cluster and all Ceph disks are being wiped, run the following command.
If disks are still reported locked, rebooting the node often helps clear LVM-related holds on disks.
If there are multiple Ceph clusters and some disks are not wiped yet, it is necessary to manually determine which disks map to which device mapper devices.
The most common issue cleaning up the cluster is that the
rook-ceph namespace or the cluster CRD remain indefinitely in the
terminating state. A namespace cannot be removed until all of its resources are removed, so determine which resources are pending termination.
If a pod is still terminating, consider forcefully terminating the pod (
kubectl -n rook-ceph delete pod <name>).
If the cluster CRD still exists even though it has been deleted, see the next section on removing the finalizer.
Removing the Cluster CRD Finalizer¶
When a Cluster CRD is created, a finalizer is added automatically by the Rook operator. The finalizer will allow the operator to ensure that before the cluster CRD is deleted, all block and file mounts will be cleaned up. Without proper cleanup, pods consuming the storage will be hung indefinitely until a system reboot.
The operator is responsible for removing the finalizer after the mounts have been cleaned up. If for some reason the operator is not able to remove the finalizer (i.e., the operator is not running anymore), delete the finalizer manually with the following command:
If the namespace is still stuck in Terminating state, check which resources are holding up the deletion and remove their finalizers as well:
Remove critical resource finalizers¶
Rook adds a finalizer
ceph.rook.io/disaster-protection to resources critical to the Ceph cluster so that the resources will not be accidentally deleted.
The operator is responsible for removing the finalizers when a CephCluster is deleted. If the operator is not able to remove the finalizers (i.e., the operator is not running anymore), remove the finalizers manually: