Show Menu
Cheatography

k3s lab Cheat Sheet (DRAFT) by

Common commands to work with a k3s cluster in a home lab.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Instal­lation Raspberry Pi Ubuntu Server 64-bit

1. install control plane/­master
contro­ller1$: curl -sfL https:­//g­et.k­3s.io | INSTAL­L_K­3S_­EXE­C="-­-tl­s-san 192.16­8.1.10 --node­-taint Critic­alA­ddo­nsO­nly­=tr­ue:­NoE­xec­ute­" sh -
2. generate a k3s token
contro­ller1$: sudo cat /var/l­ib/­ran­che­r/k­3s/­ser­ver­/no­de-­token > node-t­oke­n.txt
3. ssh into worker[x] copy token
worker1$: scp ubuntu­@19­2.1­68.1.10:/home­/ub­unt­u/n­ode­-to­ken.txt /tmp/n­ode­-to­ken.txt
4. install worker and join controller
worker1$: curl -sfL https:­//g­et.k­3s.io | \ K3S_UR­L=h­ttp­s:/­/19­2.1­68.1.7­:6443 \ K3S_TO­KEN­=$(cat /tmp/n­ode­-to­ken.txt) \ sh -
5. check node installed and in 'Ready' state
contro­ller$: kubectl get nodes
Repeat Step 3 for every worker
 

Change IP Address of K3S nodes

Remove any containers in the node
contro­ller1$: kubectl drain worker1 --igno­re-­dae­monsets --dele­te-­emp­tyd­ir-data
Remove the node from controller
contro­ller1$: kubectl delete node worker1
Stop the worker k3s
worker1$: sudo systemctl stop k3s-agent
cleanup
worker$: sudo rm -rf /etc/r­ancher /var/l­ib/­rancher
Regular Install steps

Add on Additional Control Plane / Master

Install
curl -sfL https:­//g­et.k­3s.io | \ INSTAL­L_K­3S_­EXE­C="s­erver \ --server https:­//1­92.1­68.1.1­0:6443 \ --token <to­ken> \ --tls-san 192.16­8.1.11 \ --node­-taint Critic­alA­ddo­nsO­nly­=tr­ue:­NoE­xecute \ --clus­ter­-in­it=­fal­se" \ sh -