Remove or replace a controller

You can manually remove or replace a controller from a multi-node k0s cluster (>=3 controllers) without downtime. However, you have to maintain quorum on Etcd while doing so.

Remove a controller

If your controller is also a worker (k0s controller --enable-worker), you first have to delete the controller from Kubernetes itself. To do so, run the following commands from the controller:

  1. # Remove the containers from the node and cordon it
  2. k0s kubectl drain --ignore-daemonsets --delete-emptydir-data <controller>
  3. # Delete the node from the cluster
  4. k0s kubectl delete node <controller>

Then you need to remove it from the Etcd cluster. For example, if you want to remove controller01 from a cluster with 3 controllers:

  1. # First, list the Etcd members
  2. k0s etcd member-list
  3. {"members":{"controller01":"<PEER_ADDRESS1>", "controller02": "<PEER_ADDRESS2>", "controller03": "<PEER_ADDRESS3>"}}
  4. # Then, remove the controller01 using its peer address
  5. k0s etcd leave --peer-address "<PEER_ADDRESS1>"

The controller is now removed from the cluster. To reset k0s on the machine, run the following commands:

  1. k0s stop
  2. k0s reset
  3. reboot

Replace a controller

To replace a controller, you first remove the old controller (like described above) then follow the manual installation procedure to add the new one.