Cheatography
https://cheatography.com
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.
Installation Raspberry Pi Ubuntu Server 64-bit
1. install control plane/master |
controller1$: curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--tls-san 192.168.1.10 --node-taint CriticalAddonsOnly=true:NoExecute" sh - |
2. generate a k3s token |
controller1$: sudo cat /var/lib/rancher/k3s/server/node-token > node-token.txt |
3. ssh into worker[x] copy token |
|
4. install worker and join controller |
worker1$: curl -sfL https://get.k3s.io | \ K3S_URL=https://192.168.1.7:6443 \ K3S_TOKEN=$(cat /tmp/node-token.txt) \ sh - |
5. check node installed and in 'Ready' state |
controller$: kubectl get nodes |
Repeat Step 3 for every worker |
|
|
Change IP Address of K3S nodes
Remove any containers in the node |
controller1$: kubectl drain worker1 --ignore-daemonsets --delete-emptydir-data |
Remove the node from controller |
controller1$: kubectl delete node worker1 |
Stop the worker k3s |
worker1$: sudo systemctl stop k3s-agent |
cleanup |
worker$: sudo rm -rf /etc/rancher /var/lib/rancher |
Regular Install steps |
Add on Additional Control Plane / Master
|
|
MacOS Administration Machine
1. MACOS Install Kubectl |
brew install kubernetes-cli |
2. MACOS verify |
kubectl version --client |
3. MACOS SSH into K3s control plane |
|
4. LINUX: Copy config to home drive |
sudo cat /etc/rancher/k3s/k3s.yaml > k3s2.yaml |
5. MACOS |
|
The kubeconfig file contains the credentials and endpoint information needed to connect securely to your K3s cluster. This file resides on your K3s server node
Development Workflow
MACOS install Rancher Desktop |
brew install --cask rancher |
MACOS Create project add docker file |
FROM payara/micro:latest COPY target/my-jsf-app.war /opt/payara/micro/deployments/ CMD ["--clustermode", "kubernetes"] |
|