Setup Your Own Kubernetes Cluster with K3s - Take 2 - k3sup
Despite the fact, that setting up a k3s
cluster is as easy as eating pie, using a little helper called k3s
makes it even more easier.
Cleanup #
Pleas note: In case there is already a k3s
cluster in place, maybe because of this post, it is also very easy to get rid of everything.
On the server this script has to be run:
/usr/local/bin/k3s-uninstall.sh
Analog to that, on the agent:
/usr/local/bin/k3s-agent-uninstall.sh
On the local machine the Kubernetes config under ~/.kube/config
needs to be cleaned up, too.
Prerequisites #
Additionally to having a bunch of VMs or bare-metal servers, it is also required to have two password-less SSH login and password-less sudo already being setup 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, in case 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>
For some reason the server address in .kube/config
was server: https://127.0.0.1:6443
, I have changed this to my host by hand.
The agents are joined by executing this statement:
k3sup join --host <agent-hostname> --server-host <server-hostname> --user <username>
A good test on the local machine is to list all the nodes with
kubectl get nodes -o wide
Enjoy!