To get going with Kubernetes (K8s) we need to install a distribution of K8s. For this tutorial I will use K3s by Rancher Labs.
You should replace my username and node names in the instructions below. For reference, my username is
dllewellyn, and my nodes are named as follows:
- Login to the first node:
- On the first node run the K3s installation script that automates everything - enter your sudo password if you are prompted:
curl -sfL https://get.k3s.io | sh -
- Get the token for joining more nodes to the cluster - save this somewhere you can easily copy and paste:
sudo cat /var/lib/rancher/k3s/server/node-token
- Login to the second node in a new terminal session:
- Install and join the node to the primary node we installed above - if your second node cannot resolve the primary node's name to its IP address then use the IP address directly - Replace
mynodetokenwith the node-token you saved above:
curl -sfL https://get.k3s.io | K3S_URL=https://k8s-1:6443 K3S_TOKEN=mynodetoken sh -
K3S_URLis the URL of your primary server in the cluster.
K3S_TOKENwill be used to authenticate the new node when joining the cluster. It must match with the token in the file
/var/lib/rancher/k3s/server/node-tokenon the primary server.
This is done exactly the same way as the second node, so the steps are omitted. Repeat the same steps you used for the second node, ensuring that you are in a session on the third node: