To not lose the data you need to backup PV and then execute kubeadm reset
command.
kubeadm reset
is responsible for cleaning up a node local file system from files that were created using the kubeadm init
or kubeadm join
commands. For control-plane nodes reset
also removes the local stacked etcd member of this node from the etcd cluster and also removes this node's information from the kubeadm ClusterStatus
object. ClusterStatus
is a kubeadm managed Kubernetes API object that holds a list of kube-apiserver endpoints.
kubeadm reset phase
can be used to execute the separate phases of the above workflow. To skip a list of phases you can use the --skip-phases
flag, which works in a similar way to the kubeadm join
and kubeadm init
phase runners.
The "reset" command executes the following phases:
preflight Run reset pre-flight checks
update-cluster-status Remove this node from the ClusterStatus object.
remove-etcd-member Remove a local etcd member.
cleanup-node Run cleanup node.
Take a look: kubeadm-reset.
While normal usage of cluster to not lose the PV make sure that it has Retain Reclaim Policy. Otherwise execute kubectl patch pv <your-pv-name> -p "{\"spec\":{\"persistentVolumeReclaimPolicy\":\"Retain\"}}"
. PVs then will not be automatically deleted when a user deletes claim.