Kubernetes
k3s Production Cluster on Linux with Traefik and Longhorn Basics
- Author :Liam K.
- Date :August 3, 2026
- Time :22 minutes
k3s is a certified Kubernetes distribution optimized for edge and small production clusters. It ships with sensible defaults, uses less memory than full kubeadm stacks, and still supports Helm, Ingress, and CSI storage. This guide builds a multi-node cluster suitable for internal platforms and self-hosted apps.
Prerequisites
- At least one control-plane VM and one worker (2+ CPU / 4 GB each)
- Open ports between nodes: 6443, 10250, and flannel/VXLAN as required
- DNS or MetalLB/cloud LB plan for Ingress
Step 1: Install the First Server Node
bash
curl -sfL https://get.k3s.io | sh -s - server \
--write-kubeconfig-mode 644 \
--tls-san k3s.example.com \
--disable traefik=false
sudo kubectl get nodes
sudo cat /var/lib/rancher/k3s/server/node-tokenStep 2: Join Worker Nodes
bash
# On each worker
curl -sfL https://get.k3s.io | K3S_URL=https://CONTROL_PLANE_IP:6443 \
K3S_TOKEN='NODE_TOKEN_FROM_SERVER' sh -s - agent
# Back on server
sudo kubectl get nodes -o wideStep 3: Configure kubectl Locally
bash
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $USER:$USER ~/.kube/config
sed -i 's/127.0.0.1/CONTROL_PLANE_IP/' ~/.kube/config
kubectl get pods -AStep 4: Deploy a Sample App with Ingress
bash
kubectl create deployment whoami --image=traefik/whoami:v1.10
kubectl expose deployment whoami --port=80
kubectl apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami
annotations:
[...]Command truncated. Copy to view full command.
Step 5: Add Longhorn for Persistent Volumes
bash
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.7.2/deploy/longhorn.yaml
kubectl -n longhorn-system get pods
# Create a PVC using storageClassName: longhorn for stateful workloadsStep 6: Backup etcd and Plan Upgrades
bash
sudo k3s etcd-snapshot save --name pre-upgrade
sudo ls /var/lib/rancher/k3s/server/db/snapshots
# Upgrade control plane first, then agents, following k3s release notes
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.31.4+k3s1 sh -s - serverProduction Checklist
- Protect kubeconfig and the node token like root credentials.
- Take etcd snapshots before upgrades and store them off-node.
- Separate system and app node pools when the cluster grows.
- Enable TLS on Ingress for public hostnames (cert-manager or Traefik ACME).
- Monitor node disk pressure — Longhorn and container images fill disks quickly.
"Lightweight Kubernetes still needs real operations: snapshots, upgrades, ingress TLS, and storage capacity planning."
Technical Author

Liam K.
System administrator and technical writer specializing in server infrastructure, security and deployment. Creating comprehensive guides to help you master server administration.