Install K3s Server On Ubuntu 20.04
This tutorial shows you how to install K3s on a server to make it one of your "master" controller servers. This tutorial assumes you have followed the previous tutorials on setting up the database for Kubernetes, and have set up the load balancer.
I would recommend installing at least 3 of these "controller" servers. Initially I started with just 2 and it looked like they were "fighting" with 100% CPU utilization. Setting up 3 servers means there can be a consensus with 2 overriding a third.
I gave these servers 1GB of RAM and 2 vCPUs. Rancher recommends at least 1GB.
First we need to export the variable for K3S to know how to connect to our database:
DB_USER="kubernetes" DB_PASSWORD="mySuperSecretPassword" DB_IP="192.168.0.72" DB_PORT=3306 DB_NAME="kubernetes" export K3S_DATASTORE_ENDPOINT="mysql://$DB_USER:$DB_PASSWORD@tcp($DB_IP:$DB_PORT)/$DB_NAME"
Then we can run the following command to install K3S (be sure to swap out the variable for the IP of your load balancer.
LOAD_BALANCER_IP=192.168.0.73 sudo curl -sfL https://get.k3s.io | \ sh -s - server \ --node-taint CriticalAddonsOnly=true:NoExecute \ --tls-san $LOAD_BALANCER_IP
After a few seconds, K3s will be installed and runnning.
Test It's Running
If you run the following command:
sudo k3s kubectl get node
... you should get a list of all the nodes in your cluster. For me this output the following after having installed on two servers:
NAME STATUS ROLES AGE VERSION kube2 NotReady control-plane,master 49m v1.21.1+k3s1 kube1 Ready control-plane,master 51m v1.21.1+k3s1 kube3 Ready control-plane,master 18s v1.21.1+k3s1
First published: 23rd June 2021