K3S
K3S is a lightweight Kubernetes distribution. It is easy to set up and manage, and it can be deployed on a variety of hardware platforms.
k3sup
k3sup, pronounced ‘ketchup’ is a utility that makes it easy to set up a K3S cluster. It can be used to deploy a cluster on a single node or multiple nodes, and it can be configured to use a variety of cloud providers or on-premises infrastructure.
How did I setup a K3S cluster?
- For the kubernetes cluster:
- Deployed 3 Ubuntu Server VMs(22.04.3) with 4 vCPUs and 4GB RAM each
- On my Ubuntu dekstop
- Installed k3sup
- Setup login by certificate to the 3 Ubuntu Server VMs.
- Enabled passwordless sudo on the 3 Ubuntu Server VMs.
- Used k3sup to install the k3s cluster
- Used k3sup to join worker nodes to the k3s cluster
Step by step
- Create 3 Ubuntu Server VMs
- Configure login using certificates, Refer Login using certificates
- Configure paswordless sudo. Refer No more password prompts when using sudo
- Install k3sup
curl -sLSf https://get.k3sup.dev | sh
sudo install -m k3sup /usr/local/bin/
- Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -m kubectl /usr/local/bin
- Make a note of the k3s release you want to use for your Kubernetes Cluster from here: https://github.com/k3s-io/k3s/releases
- I used version
v1.26.9+k3s1
- I used version
- You will need the following information to use as arguments for k3sup.
Hostname or IP Address of the 3 Ubuntu Server VMs you setup
User account for which you enabled login using certificates and passwordless sudo
K3S version from https://github.com/k3s-io/k3s/releases
- Deploy kubernetes to the first node. The first node will be the master node. You can configure additional master nodes or worker nodes using
k3sup join
later.
k3sup install --host k3s01.zion --cluster --k3s-version v1.26.9+k3s1 --user jahnin
If you get the following error, make sure you have setup passwordless sudo. Refer No more password prompts when using sudo
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
Error: error received processing command: Process exited with status 1
- After cluster installation, test your cluster
export KUBECONFIG=/home/jahnin/kubeconfig
kubectl config use-context default
kubectl get node -o wide
- Add the other 2 VMs as worker nodes
k3sup join --host k3s02.zion --server-host k3s01.zion --user jahnin --k3s-version v1.26.9+k3s1
k3sup join --host k3s03.zion --server-host k3s01.zion --user jahnin --k3s-version v1.26.9+k3s1
- After installation, check the nodes in your cluster
kubectl get node -o wide
Clean Up
If for whatever reason you need to clean up any of the nodes, use the following command:
/usr/local/bin/k3s-uninstall.sh