K3s: Difference between revisions
 imported from old wiki  | 
				|||
| Line 226: | Line 226: | ||
services.rpcbind.enable = true;  | services.rpcbind.enable = true;  | ||
</syntaxHighlight>  | </syntaxHighlight>  | ||
== Upkeep ==  | |||
=== Cluster Reset ===  | |||
Disable K3s instances in **all** hosts:  | |||
In NixOS configuration, set:  | |||
  services.k3s.enable = false;  | |||
Rebuild NixOS. This is going to remove K3s service files. But it won't delete K3s data.  | |||
To delete K3s files:  | |||
Dismount kubelet:  | |||
  KUBELET_PATH=$(mount | grep kubelet | cut -d' ' -f3);  | |||
  ${KUBELET_PATH:+umount $KUBELET_PATH}  | |||
Delete k3s data:  | |||
  rm -rf /etc/rancher/{k3s,node};  | |||
  rm -rf /var/lib/{rancher/k3s,kubelet,longhorn,etcd,cni}  | |||
When using Etcd, Reset Etcd:  | |||
Certify **all** K3s instances are stopped, because a single instance can re-seed etcd database with previous cryptographic key.  | |||
Disable etcd database in NixOS configuration:  | |||
  services.etcd.enable = false;  | |||
Rebuild NixOS.  | |||
Delete etcd files:  | |||
  rm -rf /var/lib/etcd/  | |||
Reboot hosts.  | |||
In NixOS configuration:  | |||
  Re-enable Etcd first. Rebuild NixOS. Certify service health. (systemctl status etcd)  | |||
  Re-enable K3s second. Rebuild NixOS. Certify service health. (systemctl status k3s)  | |||
Etcd & K3s cluster will be provisioned new.  | |||
Tip: Use Ansible to automate reset routine, like [https://gist.github.com/superherointj/d496714ddf218bdcd1c303dbfd834a5b this].  | |||
== Troubleshooting ==  | == Troubleshooting ==  | ||