Add a Agent Node to your k3s Kubernetes Cluster

In a previous post we installed a k3s node as a master and in this post we will add another node, a agent node in this case.

Retrieve the server token from the master node:

$ cat /var/lib/rancher/k3s/server/node-token
K102xxxxxxxxxxx::server:xx  

From the new agent node, run the installation and pass the k3s_token as an environment variable, and provide the master endpoint:

$ curl -sfL https://get.k3s.io | K3S_TOKEN= K102xxxxxxxxxxx::server:xx sh -s -  agent --server https://192.168.0.2:6443

Then from the master node, view the nodes in the cluster:

$ kubectl get nodes
NAME     STATUS   ROLES    AGE     VERSION  
rpi-06   Ready    master   24h     v1.18.2+k3s1  
rpi-05   Ready    <none>   6m44s   v1.18.2+k3s1