
K3s Installation Guide
K3s is a lightweight Kubernetes distribution designed for resource-constrained environments, perfect for home labs and edge computing. This guide will walk you through the installation process from start to finish.
Prerequisites
- A machine running Linux (Ubuntu 20.04+ recommended)
- Minimum 1GB RAM (2GB+ recommended for multi-workload clusters)
- 20GB+ of disk space
- Root access or sudo privileges
Basic Installation
The simplest way to install K3s is using the installation script:
curl -sfL https://get.k3s.io | sh -
This will install K3s as a server and start the service. To verify it’s running:
sudo k3s kubectl get node
Advanced Installation Options
Master Node with Custom Options
For more control, you can use environment variables:
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" sh -
Adding Worker Nodes
- On your master node, get the node token:
sudo cat /var/lib/rancher/k3s/server/node-token
- On each worker node, run:
curl -sfL https://get.k3s.io | K3S_URL=https://<master-node-ip>:6443 K3S_TOKEN=<node-token> sh -
Accessing the Cluster
After installation, the kubeconfig file is written to /etc/rancher/k3s/k3s.yaml
. To use kubectl externally:
- Copy this file to your local machine
- Set the KUBECONFIG environment variable:
export KUBECONFIG=/path/to/k3s.yaml
Uninstalling K3s
If you need to uninstall:
- On server nodes:
/usr/local/bin/k3s-uninstall.sh
- On agent nodes:
/usr/local/bin/k3s-agent-uninstall.sh
Next Steps
Now that you have K3s running, you might want to:
- Deploy your first application
- Set up persistent storage
- Configure ingress for external access
Stay tuned for more guides on these topics!