Although setting up a k3s cluster is as easy as pie, using a little helper called k3sup makes it even easier.

Cleanup

Please note: if there is already a k3s cluster in place (for example because of this post), it is also very easy to remove everything.

On the server run:

/usr/local/bin/k3s-uninstall.sh

On the agent run:

/usr/local/bin/k3s-agent-uninstall.sh

On the local machine, the Kubernetes config under ~/.kube/config needs to be cleaned up as well.

Prerequisites

In addition to having a bunch of VMs or bare-metal servers, you need passwordless SSH logins and passwordless sudo already set up in order to use k3sup.

Here are two posts I quickly put together that explain exactly that:

Of course, the tool k3sup is also needed. It can be installed by executing the following:

curl -sLSf https://get.k3sup.dev | sh
sudo install -m k3sup /usr/local/bin/

Cluster Installation

With everything in place, the k3s server can be installed with:

k3sup install --ip <ip-of-server> --user <user-name> --local-path ~/.kube/config --context <mycontext>

Or, if you want to provide the hostname instead of an IP:

k3sup install --host <hostname-of-server> --user <user-name> --local-path ~/.kube/config --context <mycontext>

In my case, the server address in .kube/config was server: https://127.0.0.1:6443; I changed this to my host manually.

Join agents with:

k3sup join --host <agent-hostname> --server-host <server-hostname> --user <username>

To test, list all the nodes on the local machine with:

kubectl get nodes -o wide

Enjoy!

Resources