How to Install a Single-Node Kubernetes Cluster with k3s

k3s is a lightweight, certified Kubernetes distribution designed to run efficiently on modest hardware, including a single VPS. This guide covers installing a fully working single-node cluster.

Why k3s Instead of Full Kubernetes

k3s strips out rarely-needed components and ships as a single small binary, using far less memory than a standard kubeadm-based install — ideal for a single VPS or small clusters, without sacrificing compatibility with standard Kubernetes tooling (kubectl, Helm charts all work normally).

Prerequisites

  • Ubuntu 22.04/24.04 VPS: 2 vCPU, 4 GB RAM minimum
  • Root or sudo access

Step 1 — Install k3s

curl -sfL https://get.k3s.io | sh -

This single command installs k3s as a systemd service and starts it automatically.

Step 2 — Verify the Node Is Ready

sudo kubectl get nodes

Should show one node with status Ready.

Step 3 — Set Up kubectl Access Without sudo

mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
export KUBECONFIG=~/.kube/config

Add the export line to ~/.bashrc to persist it across sessions.

Step 4 — Deploy a Test Application

kubectl create deployment nginx-test --image=nginx
kubectl expose deployment nginx-test --port=80 --type=NodePort

Step 5 — Find the Assigned Port and Test

kubectl get svc nginx-test
curl http://localhost:PORT_SHOWN_ABOVE

Step 6 — Clean Up the Test Deployment

kubectl delete deployment nginx-test
kubectl delete service nginx-test

Allowing External Access Through the Firewall

sudo ufw allow 6443/tcp

Port 6443 is the Kubernetes API server; only open it if you genuinely need remote kubectl access from outside the server itself.

Checking k3s Service Status

sudo systemctl status k3s

Viewing k3s Logs

sudo journalctl -u k3s -f

Uninstalling k3s (If Needed)

sudo /usr/local/bin/k3s-uninstall.sh

Next Steps

Once your single-node cluster is running, see Kubernetes Pods, Deployments & Services Explained to understand the core building blocks, and How to Deploy a Stateless Web App to Kubernetes (Step-by-Step) for a real deployment walkthrough.

Common Errors

"kubectl: command not found" — k3s installs kubectl automatically; verify with which kubectl, or use k3s kubectl explicitly if the standalone binary isn't linked.

Node shows "NotReady" — wait 30-60 seconds after install for all system components to initialize; check sudo journalctl -u k3s for specific errors if it persists.

Best Practices

  • Use k3s for single-node or small multi-node setups rather than full kubeadm, unless you have a specific reason requiring the complete upstream distribution
  • Restrict API server access (port 6443) to trusted IPs if enabling remote access
  • Keep k3s updated for security patches

Continue Reading

Browse more articles in Kubernetes & Container Orchestration.

  • k3s, single node kubernetes, lightweight kubernetes, k3s installation
  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

What Is Kubernetes and When Do You Need It on a VPS?

Kubernetes is a container orchestration platform — it automates deploying, scaling, and...

How to Install kubeadm and Set Up a Multi-Node Kubernetes Cluster

kubeadm is the official tool for bootstrapping a standard, full-featured Kubernetes cluster. This...

Kubernetes Pods, Deployments & Services Explained

Understanding these three core Kubernetes objects — Pods, Deployments, and Services —...

How to Expose Applications with a Kubernetes Ingress Controller (Nginx Ingress)

An Ingress lets you route external HTTP/HTTPS traffic to multiple services within your cluster...

How to Manage Persistent Storage in Kubernetes (PersistentVolumes & PVCs)

Containers are ephemeral by design — data written inside them disappears when the Pod is...