When you delete a node using the CLI, the node object is deleted in Kubernetes
, but the pods that exist on the node are not deleted. Any bare pods not backed by a replication controller become inaccessible to OpenShift Container Platform
. Pods backed by replication controllers are rescheduled to other available nodes. You must delete local manifest pods.
- To delete the node from the UPI installation, the node must be firstly drained and then marked
unschedulable
prior to deleting it:
$ oc adm cordon <node_name> $ oc adm drain <node_name> --force --delete-local-data --ignore-daemonsets - Ensure also that there are no current jobs/cronjobs being ran or scheduled in this specific node as the draining does not take it into consideration. - For Red Hat OpenShift Container Platform 4.7+, utilize the option `--delete-emptydir-data` in case `--delete-local-data` doesn't work. The `--delete-local-data` option is deprecated in favor of `--delete-emptydir-data`. $ oc get node <node_name> -o yaml > backupnode.yaml Before proceeding with deletion of the node, it needs to be under "power off" status: $ oc delete node <node_name>
Although the node object is now deleted from the cluster, it can still rejoin the cluster after reboot or if the kubelet service is restarted. To permanently delete the node and all its data, you must decommission the node once it is in shutdown mode.
Once the node is deleted, it can be ready for a power-off activity, or if it is needed to rejoin the cluster, it could be possible to either restart the kubelet or create the yaml back:
$ oc create -f backupnode.yaml
In order to get the node back, it can also be back by restarting kubelet:
$ systemctl restart kubelet
If it is needed to destroy then all the data from the worker node to delete all the software installed, execute the following:
# nohup shred -n 25 -f -z /dev/[HDD]
This command will overwrite all data on /dev/[HDD] repeatedly, in order to make it harder for even very expensive hardware probing to recover the data. Command line parameter -z will overwrite this device with zeros at the end of cycle to re-write data 25 times (it can be overridden with -n [number]).
One should consider running this command from RescueCD.
In order to monitor the deletion of the node, get the kubelet
live logs:
$ oc adm node-logs <node-name> -u kubelet