2024-07-27
K3S Change Data Storage Path

you can configure K3S_DATA_DIR environment variable during installation


first, stop all k3s services

1
2
3
4
# run with root
systemctl stop k3s # k3s-agent otherwise
k3s-killall.sh

copy the data to new location

1
2
rsync -avh --progress /var/lib/rancher/k3s <path_to_store_data>

then modify the service file under /etc/systemd/system/k3s.service or /etc/systemd/system/k3s-agent.service, add one additional flag --data-dir <path_to_store_data> to the commandline

restart the service after done

1
2
3
systemctl daemon-reload
systemctl start k3s

Read More

2024-07-24
Setting Up A K8S Worker Cluster With K3S: Instructions, Configuration Files, And Automated Installation Tool

k8s worker cluster setup

k3s has different ways to form a cluster than kubeadm join.

https://docs.k3s.io/quick-start

k3s specifies the init command in /etc/systemd/system/k3s.service. (k3s-agent.service if installed as agent) usually it is k3s server.

you need to change it to k3s agent in order to join the master node, or pass additional environment variables K3S_URL=https://<node_ip>:6443 and K3S_TOKEN=<node-token> while running k3s installation script.

the node token is at /var/lib/rancher/k3s/server/node-token

the agent node still needs to configure registry mirrors at /etc/rancher/k3s/registries.yaml for successfully pulling images


k3sup can automatically install k3s cluster using ssh connection


multi server cluster setup:

https://docs.k3s.io/datastore/ha-embedded

Read More