Deploying k3s
Installing the master
To deploy Kubernetes, we need to SSH into the VMs. Assuming we are using the
official docker image with fish integration, we can write detee-cli vm ssh master
and hit the TAB key. This will autocomplete the UUID needed to identify
the VM and to SSH. The command allows the --just-print
parameter if we want to
show the SSH command without connecting.
root@e2d98b4ae6e1 /# detee-cli vm ssh 92ceeba2-0f2c-4dac-8a0c-942a52e9f074 --just-print
To SSH into k3s-master (UUID: 92ceeba2-0f2c-4dac-8a0c-942a52e9f074), run the following command:
ssh -i /root/.ssh/id_ed25519 -p 22 root@173.234.136.155
root@e2d98b4ae6e1 /# detee-cli vm ssh 92ceeba2-0f2c-4dac-8a0c-942a52e9f074
Running SSH command: ssh -i /root/.ssh/id_ed25519 -p 22 root@173.234.136.155
[root@k3s-master ~]#
On the k3s-master
node, we should first upgrade the software and install
curl
:
pacman -Syu --noconfirm
pacman -S curl --noconfirm
After this we can install k3s by running:
curl -sfL https://get.k3s.io | sh -
Installing workers
After the master node got installed, we can get the token of the master node to
install additional nodes in this cluster. You can find the token in the file
/var/lib/rancher/k3s/server/node-token
on the master node:
[root@k3s-master ~]# cat /var/lib/rancher/k3s/server/node-token
K10cc4e73cdf765636f89e34ec84c7698972bf52499fdd162acd60a084ed70ceca6::server:89e69f56769aca094fc5bc804efcc7e1
Now we can just get the IP of the master node, and SSH into k3s-node-1
to
install it as a worker node in the cluster:
root@e2d98b4ae6e1 /# FORMAT=YAML detee-cli vm inspect 92ceeba2-0f2c-4dac-8a0c-942a52e9f074 | grep ipv4
public_ipv4: 173.234.136.155
~# detee-cli vm ssh d811af7e-83a0-40fe-b83f-a4fec2cc7608
Running SSH command: ssh -i /root/.ssh/id_ed25519 -p 22 root@173.234.137.17
[root@k3s-node-1 ~]# curl -sfL https://get.k3s.io | K3S_URL=https://173.234.136.155:6443 K3S_TOKEN=K10cc4e73cdf765636f89e34ec84c7698972bf52499fdd162acd60a084ed70ceca6::server:89e69f56769aca094fc5bc804efcc7e1 sh -
# ... log removed
[INFO] systemd: Starting k3s-agent
[root@k3s-node-1 ~]#
As you probably observed, the command for the worked node is:
curl -sfL https://get.k3s.io | K3S_URL=https://173.234.136.155:6443 K3S_TOKEN=K10cc4e73cdf765636f89e34ec84c7698972bf52499fdd162acd60a084ed70ceca6::server:89e69f56769aca094fc5bc804efcc7e1 sh -
[INFO] Finding release for channel stable
[INFO] Using v1.32.3+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.32.3+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.32.3+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
main: line 597: [: : integer expression expected
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
Created symlink '/etc/systemd/system/multi-user.target.wants/k3s-agent.service' → '/etc/systemd/system/k3s-agent.service'.
[INFO] systemd: Starting k3s-agent
Listing all nodes
You can go ahead and run this command also on the 3rd node. After that, log into
k3s-master
and check the available nodes with kubectl
:
[root@k3s-master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
k3s-master Ready control-plane,master 16m v1.32.3+k3s1
k3s-node-1 Ready <none> 3m16s v1.32.3+k3s1
k3s-node-2 Ready <none> 3s v1.32.3+k3s1