25/11/2026
k3s Installation Guide: Online and Air-Gapped
So you've decided to go with Kubernetes. (Still not sure? Read Docker Compose or Kubernetes first.) Now the question is: where do you start without spending two weeks on the install?
So you've decided to go with Kubernetes. (Still not sure? Read Docker Compose or Kubernetes first.) Now the question is: where do you start without spending two weeks on the install?
Our usual answer is k3s. It's a lightweight Kubernetes distribution. Everything you need is in one binary. It exposes the same Kubernetes APIs, so what you learn here carries over to bigger clusters later.
At ITcorv we install k3s both online and on networks with no internet, or with internet you can't count on. This post covers both. The examples work on Ubuntu 22.04/24.04 and Debian 12.
What is a k3s installation?
A k3s installation means you get a lightweight Kubernetes distribution from a single binary, instead of installing the control plane, runtime and networking separately. One install gives you:
- Kubernetes itself (API server, scheduler and the rest)
- containerd as the runtime, so no Docker needed
- Flannel for pod networking
- CoreDNS
- Traefik as the Ingress controller
- local-path for storage
- metrics-server
- a simple load balancer called servicelb
Don't want one of them? Turn it off with disable. We'll show how below.
Before you install
- Every node needs a unique hostname. If it doesn't have one, pass
K3S_NODE_NAMEduring install. - Open these ports between nodes:
| Port | Protocol | What for | |---|---|---| | 6443 | TCP | API and node-to-server connection | | 8472 | UDP | Flannel VXLAN (between nodes only) | | 10250 | TCP | kubelet and metrics-server | | 2379-2380 | TCP | only for HA with embedded etcd |
One important thing: never expose port 8472 to the internet. Anyone who reaches it reaches your cluster network. We covered the server firewall in Linux server hardening.
1. Online install (single node)
If the server has internet access, it's one line:
curl -sfL https://get.k3s.io | sh -The script installs k3s as a systemd service. If the server reboots or the process dies, it comes back on its own. It also installs kubectl, crictl and ctr. The kubeconfig goes to /etc/rancher/k3s/k3s.yaml.
To pin the version, also set INSTALL_K3S_VERSION=v1.33.3+k3s1 (the same version you use for air-gap). If get.k3s.io or GitHub is unreachable from Iran, use the air-gap method below.
That single node is already a full cluster. Good enough to start and test.
2. The config file
Instead of putting flags in the command, put them in a file. That way you'll remember what you set. k3s reads this file on its own:
/etc/rancher/k3s/config.yaml
Create the folder first, or you'll get No such file or directory:
sudo mkdir -p /etc/rancher/k3swrite-kubeconfig-mode: "0644"
tls-san:
- "k3s.example.local"
- "10.10.10.10"
node-label:
- "env=prod"
disable:
- "traefik"tls-san: the name or IP you'll use to reach the cluster withkubectlfrom outside. Without it, the certificate isn't valid for that address.disable: here we turned off Traefik, say because we want ingress-nginx. If Traefik works for you, delete this line.write-kubeconfig-mode: makes the kubeconfig readable by everyone. Handy on a personal or test server. Don't use it on a shared server, since that file is cluster-admin access.
Best to create this file before installing. If you change it later, run sudo systemctl restart k3s.
3. Adding a node (agent)
On the first server, grab the token:
sudo cat /var/lib/rancher/k3s/server/node-tokenThen on the new node:
curl -sfL https://get.k3s.io | K3S_URL=https://10.10.10.10:6443 K3S_TOKEN=<token> sh -When you set K3S_URL, the script installs an agent instead of a server, and the node registers with the server.
4. Offline install (air-gap)
A lot of production servers have no internet, or GitHub downloads drop halfway. That's where air-gap helps. You download three files once on a machine with internet, then carry them to the servers.
All files must be from the same version. We use v1.33.3+k3s1 as the example; pick the version you want from the k3s releases page on GitHub.
On the machine with internet:
VER="v1.33.3%2Bk3s1"
curl -Lo k3s https://github.com/k3s-io/k3s/releases/download/${VER}/k3s
curl -Lo k3s-airgap-images-amd64.tar.zst https://github.com/k3s-io/k3s/releases/download/${VER}/k3s-airgap-images-amd64.tar.zst
curl -Lo install.sh https://get.k3s.io(%2B is just + written for a URL.)
This example is for amd64. For arm64 the files are k3s-arm64 and k3s-airgap-images-arm64.tar.zst; install the binary as /usr/local/bin/k3s.
Copy these three files to every node with scp or a USB stick. Then on each node:
sudo mkdir -p /var/lib/rancher/k3s/agent/images/
sudo cp k3s-airgap-images-amd64.tar.zst /var/lib/rancher/k3s/agent/images/
sudo cp k3s /usr/local/bin/k3s
sudo chmod +x /usr/local/bin/k3s
chmod +x install.shOn the server:
sudo INSTALL_K3S_SKIP_DOWNLOAD=true ./install.shOn the agents:
sudo INSTALL_K3S_SKIP_DOWNLOAD=true K3S_URL=https://10.10.10.10:6443 K3S_TOKEN=<token> ./install.shINSTALL_K3S_SKIP_DOWNLOAD=true tells the script not to download anything and use the binary you placed. The k3s system images (like CoreDNS and Traefik) load from that tar file.
5. Your own images: registry mirror
The air-gap archive only has k3s's own images. Your app images have to come from an internal registry. k3s reads this file at startup:
/etc/rancher/k3s/registries.yaml
mirrors:
docker.io:
endpoint:
- "https://registry.example.local:5000"This means any image requested from docker.io is pulled from your internal registry first. By default, though, if the mirror doesn't respond, containerd still falls back to docker.io itself. In a true air-gap, turn that off by adding this to config.yaml:
disable-default-registry-endpoint: truePut this file on every node, servers included, since servers run pods by default. Then restart the service: sudo systemctl restart k3s on a server, sudo systemctl restart k3s-agent on an agent.
How to set up an internal registry or a Docker Hub mirror is covered in our Docker Hub in Iran post.
Test
First, check the nodes joined:
sudo kubectl get nodes -o wideThey should all be Ready.
Then the system pods:
sudo kubectl get pods -AAll should be Running or Completed. If one is stuck in ImagePullBackOff, its image wasn't found. On air-gap that usually means the tar file is in the wrong place or its version doesn't match the binary.
Now deploy a test app:
sudo kubectl create deployment web --image=nginx --replicas=2
sudo kubectl expose deployment web --port=80
sudo kubectl get pods -o wide
sudo kubectl run tmp --rm -it --image=busybox --restart=Never -- wget -qO- http://webIf you see the nginx page HTML at the end, in-cluster networking and DNS work too. (On air-gap, the nginx and busybox images must be in your internal registry.)
Clean up:
sudo kubectl delete service web
sudo kubectl delete deployment webLogs live here:
sudo journalctl -u k3s -f # on the server
sudo journalctl -u k3s-agent -f # on an agentTips
- kubectl from your laptop: copy
/etc/rancher/k3s/k3s.yamlto your laptop and replace127.0.0.1with the server address. That address must be intls-san. - One server is one point of failure: if the server goes down, running pods usually keep working, but you can't manage anything. For serious production, run three servers with embedded etcd.
- Keep critical flags identical on all servers: for example, if one server has
disable: traefikor a customcluster-cidrand the others don't, they won't join. - Faster air-gap startup: k3s re-imports the tar files every time it starts. Create an empty
.cache.jsonfile in the same images folder and only changed archives get re-imported. - Air-gap upgrades: drop in the new binary, the new tar (delete the old one) and a fresh install.sh, then rerun the script with the same variables as before.
- Uninstall:
/usr/local/bin/k3s-uninstall.shon a server,/usr/local/bin/k3s-agent-uninstall.shon an agent.
FAQ
Is k3s fine for production or just for testing?
It's fine. It exposes the same Kubernetes APIs and is built for production use. What makes production production is HA, backups and monitoring, not the distribution's name.
My server is small. Will it work?
For a single test node, a small VPS is enough. But the more pods you run, the more RAM you need. Check the minimums on the k3s docs requirements page and size for your own workload.
Keep Traefik or use nginx?
If you don't need anything special, Traefik does the job. If your team is more comfortable with nginx config, disable Traefik and install ingress-nginx.
Do you set up clusters for companies?
Yes. The ITcorv team designs and installs k3s clusters, online or fully air-gapped, along with internal registries, GitOps and Prometheus/Grafana monitoring.
See our DevOps services page. We also covered monitoring in our Prometheus and Grafana post. The full learning path is in our DevOps roadmap.