Install K3S on Machine do not have Internet Access
Date: 2024/08/16Last Updated: 2024-08-16T15:42:43.994Z
Categories: kubernetes
Tags: k3s, kubernetes
Read Time: 1 minutes
Contents
Install K3S on Machine do not have Internet Access
Introduction
K3S is a lightweight Kubernetes distribution. It is a great choice for edge computing and IoT devices. I currently have a machine with only ipv6 access, and I want to install K3S on it. Sadly, k3s install script need to download binary from GitHub, which is known to be not ipv6 friendly currently.
Prerequisites
Firewall
Make sure the machine have open several ports to allow it to communicate with other nodes.
ufw allow 6443/tcp #apiserver
ufw allow from 10.42.0.0/16 to any #pods
ufw allow from 10.43.0.0/16 to any #services
Kernel Modules
Through trying, I found that the machine need to have
br_netfilter
and overlay
kernel modules loaded.
Use the following command to check,
if it gives a fatal message,
it probabily means k3s may not supported on this machine.
Also, see https://github.com/k3s-io/k3s/issues/1236.
modprobe br_netfilter
modprobe overlay
Solution
First, from the k3s release page download the airgap image, and transfer it to the machine you want to install k3s on. Then, download the install script from https://get.k3s.io, and put it in the same directory as the airgap image, and make sure the script is executable.
chmod +x install.sh
Then, download the k3s binary from the release page,
and put it into where ever you install executable,
normally it is /usr/local/bin
.
mv k3s /usr/local/bin
chmod +x /usr/local/bin/k3s
Now, you can run the install script:
INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='server --token=SECRET' ./install.sh
To join another node to the cluster, you can run:
INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='server --server https://server-ip:6443 --token=SECRET' ./install.sh
Uninstall K3S
Uninstall K3S on Server
/usr/local/bin/k3s-uninstall.sh
Uninstall K3S on Agent
/usr/local/bin/k3s-agent-uninstall.sh