Reset (Uninstall)

Resetting k0s nodes essentially reverts them to a pre-k0s state. This operation is particularly useful in scenarios where you need to cleanly remove k0s from nodes, either for troubleshooting purposes or as a precursor to a fresh installation. It is designed to remove all components, configurations, and data associated with k0s from a node. This includes, but is not limited to, the following:

  • Processes and containers: Terminates all running k0s processes to ensure that there are no active components left. This includes all container processes managed by the Container Runtime.
  • Data stored on the node: Deletes the whole k0s data directory, which includes
    • all k0s-related configuration files, including those used for cluster setup and node-specific settings,
    • all data stores managed by k0s, including etcd or kine data for cluster state and any temporary files created during operation,
    • and all certificates and other key material generated by k0s for node authentication and communication within the cluster.
  • Network settings: Reverts any network configurations made by k0s, such as network interfaces or iptables rules set up specifically for cluster communication. This is done on a best effort basis. It’s recommended that you reboot the host after a reset to ensure that there are no k0s remnants in the host’s network configuration.
  • Registration with the host’s init system: Reverts the registration done by k0s install. After a reset, k0s won’t be automatically started when the host boots.

After a successful reset, the k0s binary itself remains. It can then be used to join another cluster or create a new one.

It’s important to understand that performing a reset is a destructive operation that will result in the loss of all data and configurations related to k0s on the affected nodes. Therefore, it should be performed with care, ideally after ensuring that all necessary data has been backed up or that the cluster can be safely disassembled without data loss.

K0s can be reset locally on a host using the k0s reset command. Whole clusters can be reset remotely with the k0sctl reset command.

Reset a k0s node locally

To ensure operational safety, k0s reset includes a safeguard that prevents it from being executed while k0s is running, so it must be stopped first:

  1. Stop the service:

    1. sudo k0s stop
  2. Invoke the reset command:

    1. $ sudo k0s reset
    2. WARN[2024-03-28 09:15:36] To ensure a full reset, a node reboot is recommended.

Reset a k0s cluster remotely using k0sctl

K0sctl can be used to connect and reset all cluster nodes in a single command.

  1. Invoke k0sctl reset command:

    1. $ k0sctl reset --config k0sctl.yaml
    2. k0sctl v0.17.4 Copyright 2023, k0sctl authors.
    3. Anonymized telemetry of usage will be sent to the authors.
    4. By continuing to use k0sctl you agree to these terms:
    5. https://k0sproject.io/licenses/eula
    6. ? Going to reset all of the hosts, which will destroy all configuration and data, Are you sure? Yes
    7. INFO ==> Running phase: Connect to hosts
    8. INFO [ssh] 13.53.43.63:22: connected
    9. INFO [ssh] 13.53.218.149:22: connected
    10. INFO ==> Running phase: Detect host operating systems
    11. INFO [ssh] 13.53.43.63:22: is running Ubuntu 22.04.4 LTS
    12. INFO [ssh] 13.53.218.149:22: is running Ubuntu 22.04.4 LTS
    13. INFO ==> Running phase: Acquire exclusive host lock
    14. INFO ==> Running phase: Prepare hosts
    15. INFO ==> Running phase: Gather k0s facts
    16. INFO [ssh] 13.53.43.63:22: found existing configuration
    17. INFO [ssh] 13.53.43.63:22: is running k0s controller version v1.30.0+k0s.0
    18. INFO [ssh] 13.53.218.149:22: is running k0s worker version v1.30.0+k0s.0
    19. INFO [ssh] 13.53.43.63:22: checking if worker has joined
    20. INFO ==> Running phase: Reset workers
    21. INFO [ssh] 13.53.218.149:22: reset
    22. INFO ==> Running phase: Reset controllers
    23. INFO [ssh] 13.53.43.63:22: reset
    24. INFO ==> Running phase: Reset leader
    25. INFO [ssh] 13.53.43.63:22: reset
    26. INFO ==> Running phase: Release exclusive host lock
    27. INFO ==> Running phase: Disconnect from hosts
    28. INFO ==> Finished in 8s