Guideschevron_rightServers

Servers · 10 min read · Updated

How to Install Kubernetes (k3s) on a Dedicated Server or VPS

To install Kubernetes on a dedicated server or VPS, use k3s: run curl -sfL https://get.k3s.io | sh - on Ubuntu or Debian, and a minute later you have a working single-node cluster with kubectl, an ingress controller and local storage. The kubeconfig is at /etc/rancher/k3s/k3s.yaml. Add more machines with the join token from /var/lib/rancher/k3s/server/node-token, and keep the API port 6443 open only to your own nodes.

One Big Server or Several Small Ones

k3s needs only 2 cores and 2 GB for a server node, so even a small VPS (Bronze, $37.50 a month) runs it for learning and light apps. For real workloads the choice is between one large dedicated server, where every pod shares fast local cores, memory and NVMe with no network in between, and three or more machines, which keep running when one fails.

Dedicated servers for a k3s cluster
ServerCores / threadsMemoryFromLocation
AMD Ryzen 9 5950X16 / 32128 GB$399.00/moAshburn, Dallas
AMD Ryzen 9 9950X16 / 32192 GB$669.00/moAshburn, Dallas
AMD EPYC 4585PX16 / 32128 GB$849.00/moDallas
AMD EPYC 7443P24 / 48512 GB$969.00/moAshburn, Dallas
AMD EPYC 9455P48 / 96512 GB$999.00/moDallas
AMD Dual EPYC 7702128 / 256512 GB$1,099.00/moAshburn, Dallas
AMD EPYC 945548 / 96512 GB$2,299.00/moDallas

1. Install the First Node

On a fresh Ubuntu 24.04 or Debian 13 server, after securing it:

curl -sfL https://get.k3s.io | sh -
sudo kubectl get nodes          # one node, STATUS Ready
sudo kubectl get pods -A        # coredns, traefik, local-path, metrics-server

k3s runs as the k3s systemd service and installs its own kubectl, which reads /etc/rancher/k3s/k3s.yaml. To use kubectl without sudo on the server:

mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $USER: ~/.kube/config
export KUBECONFIG=~/.kube/config   # add to ~/.bashrc

2. Use kubectl from Your Computer

Copy the same file to your computer as ~/.kube/config. It points at https://127.0.0.1:6443, which works through an SSH tunnel without opening the port:

ssh -N -L 6443:127.0.0.1:6443 [email protected] &
kubectl get nodes

3. Firewall Rules

With ufw, allow the pod and service networks k3s uses by default, and the API only from your nodes:

sudo ufw allow from 10.42.0.0/16 to any    # pods
sudo ufw allow from 10.43.0.0/16 to any    # services
sudo ufw allow 80,443/tcp                  # Traefik ingress
sudo ufw allow from 198.51.100.21 to any port 6443 proto tcp   # each other node
Ports k3s nodes use between each other
PortBetweenPurpose
TCP 6443Agents to serversKubernetes API and k3s supervisor
UDP 8472All nodesFlannel VXLAN; never open to the internet
UDP 51820All nodesFlannel over WireGuard, if you choose it
TCP 10250All nodesKubelet metrics and logs
TCP 2379–2380Servers onlyEmbedded etcd, for several server nodes

4. Add More Nodes

Read the token on the first server, then install k3s on each new machine as an agent:

sudo cat /var/lib/rancher/k3s/server/node-token

# on the new machine:
curl -sfL https://get.k3s.io | K3S_URL=https://203.0.113.10:6443 K3S_TOKEN=paste-token sh -

Every machine needs its own hostname. Pod traffic between nodes is not encrypted by default, so for nodes that talk over the public internet start the first server with INSTALL_K3S_EXEC="--flannel-backend=wireguard-native" instead, and open UDP 51820 between them. VPS nodes in the same location can use private networking for that traffic.

5. Deploy Something

kubectl create deployment hello --image=nginx --replicas=2
kubectl expose deployment hello --port=80

Then route a domain to it through Traefik with an Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: hello
spec:
  rules:
    - host: hello.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: hello
                port:
                  number: 80
kubectl apply -f hello-ingress.yaml

Point hello.example.com at the server and it answers on port 80. For HTTPS, install cert-manager with Helm and add a Let's Encrypt issuer.

Storage, Backups and Removal

  • Volumes: the built-in local-path storage class keeps volumes on the node under /var/lib/rancher/k3s/storage, which is fast on NVMe but tied to that node.
  • Backups: keep your manifests or Helm values in Git, and back up volumes and /var/lib/rancher/k3s/server off the server, for example to object storage.
  • Starting over: /usr/local/bin/k3s-uninstall.sh removes k3s from a server node, and k3s-agent-uninstall.sh from an agent.

Not sure you need Kubernetes? Docker Compose or Coolify run a handful of apps on one server with far less to learn.

Common Questions

  • Is k3s real Kubernetes?

    Yes. k3s is a certified Kubernetes distribution packed into one binary, with a lighter default datastore and a few add-ons included. kubectl, Helm charts and ordinary manifests work as they do on any cluster.

  • Is a single-node cluster worth it?

    For running your own apps, often yes: you get Kubernetes deployments, rolling updates, ingress and Helm on one powerful machine. It is not highly available, because the one server is the whole cluster, so keep backups and a way to rebuild.

  • What comes with k3s?

    CoreDNS, the Traefik ingress controller, a local-path storage provisioner, metrics-server and a simple built-in load balancer (ServiceLB). Turn any of them off with --disable, for example --disable=traefik to use ingress-nginx instead.

  • Should I expose port 6443 to the internet?

    No. Only other nodes need it. Reach the API from your own computer through an SSH tunnel or a WireGuard network, and allow 6443 only from your nodes' addresses.

Plans and prices

Dedicated Servers

Bare-metal servers with many cores and lots of memory: room for a whole cluster's worth of workloads on one machine.

See all plans
  • AMD Ryzen 9 5950X

    16 Cores · 128 GB RAM · 2x 1TB NVMe

    Ashburn, VA · Dallas, TX · 50 TB transfer · 10 GigE

    $399.00/mo

  • AMD Ryzen 9 9950X

    16 Cores · 192 GB RAM · 2x 2 TB NVMe

    Ashburn, VA · Dallas, TX · 50 TB transfer · 10 GigE

    $669.00/mo

  • AMD EPYC 4585PX

    16 Cores · 128 GB RAM · 2x 6.4TB NVMe Gen4

    Dallas, TX · 200 TB transfer · 50 Gbps

    $849.00/mo

  • AMD EPYC 7443P

    24 Cores · 512 GB RAM · 2x 2TB NVMe

    Dallas, TX · Ashburn, VA · 50 TB transfer · 10 GigE

    $969.00/mo

Keep Reading

All guides