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:
- k8s-1
- k8s-2
- k8s-3
Start the first node
- Login to the first node: ```bash
ssh dllewellyn@k8s-1
1. On the first node run the K3s installation script that automates everything - enter your sudo password if you are prompted:
```bash
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: ```bash
sudo cat /var/lib/rancher/k3s/server/node-token
![Screenshot of terminal output of installing the first node](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ipbws1idebu3haxq415.png)
## Start the second node
1. Login to the second node in a new terminal session:
```bash
ssh dllewellyn@k8s-2
- 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
mynodetoken
with the node-token you saved above: ```bash
curl -sfL https://get.k3s.io | K3S_URL=https://k8s-1:6443 K3S_TOKEN=mynodetoken sh -
- `K3S_URL` is the URL of your primary server in the cluster.
- `K3S_TOKEN` will 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-token` on the primary server.
![Screenshot of terminal output of installing the second node](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l35mh40r0xi6tkilifxn.png)
## Start the third node
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:
```bash
ssh dllewellyn@k8s-3
Top comments (0)