Cloud VPS

How to Set Up Lightweight Kubernetes (K3s) on a Budget Linux Cloud VPS

How to Set Up Lightweight Kubernetes (K3s) on a Budget Linux Cloud VPS - CpanelFree Guide
Written by Blog

Demystifying Kubernetes: Why Standard K8s Fails on Budget VPS

Full enterprise Kubernetes distributions (such as kubeadm, OpenShift, or EKS) are designed for massive multi-node corporate data centers. Running standard Kubernetes requires separate control plane nodes, dedicated etcd clusters, extensive overlay networking daemons, and at least 4GB to 8GB of idle RAM just to bootstrap the control plane before launching a single application pod.

K3s is a fully compliant, certified CNCF lightweight Kubernetes distribution created by Rancher Labs (SUSE). By packaging the control plane, Kubelet, Flannel CNI, CoreDNS, local path storage provisioners, and Traefik ingress controller into a single lightweight 100MB binary, K3s reduces memory consumption to under 512MB RAM. This enables developers and DevOps engineers to run production Kubernetes clusters, GitOps pipelines, and microservices on an affordable $4–$10/month cloud VPS.

In this comprehensive hands-on tutorial, we will install K3s on Ubuntu 24.04/22.04 LTS, configure kubectl management on local workstations, deploy containerized microservice deployments with PersistentVolumeClaims, and configure automated Traefik ingress routing with SSL.

Step 1: Installing K3s Control Plane on Ubuntu VPS

Installing K3s requires only a single official curl execution script that configures systemd daemons and network bridges automatically:

# Update package list and install curl
sudo apt update && sudo apt install -y curl

# Install K3s control plane with Traefik enabled
curl -sfL https://get.k3s.io | sh -

# Verify K3s systemd service status
sudo systemctl status k3s --no-pager

# Confirm node readiness via kubectl
sudo k3s kubectl get nodes

Step 2: Configuring kubectl Access for Unprivileged Users & Remote Laptops

By default, K3s stores its kubeconfig at /etc/rancher/k3s/k3s.yaml with restricted root permissions. Grant access to your standard user account:

# Create local kube configuration directory
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
chmod 600 ~/.kube/config

# Verify kubectl command works without sudo
kubectl get pods -A

To manage your K3s cluster from your local desktop laptop, copy ~/.kube/config to your computer and replace 127.0.0.1 with your VPS server’s public IPv4 address.

Step 3: Deploying a Scalable Web Application with Deployment & Service

Create a production deployment manifest webapp.yaml running 3 replicated Nginx web app pods with an internal ClusterIP service:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app-deployment
  labels:
    app: web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: nginx-web
        image: nginx:alpine
        ports:
        - containerPort: 80
        resources:
          limits:
            memory: "64Mi"
            cpu: "250m"
---
apiVersion: v1
kind: Service
metadata:
  name: web-app-service
spec:
  selector:
    app: web-app
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80

Apply the manifest to the cluster:

kubectl apply -f webapp.yaml
kubectl get pods -l app=web-app

Step 4: Exposing Microservices via Traefik Ingress Controller

K3s includes the Traefik Ingress controller out of the box. Create ingress.yaml to route public HTTP traffic from your domain to the internal service:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-app-ingress
  annotations:
    ingress.class: traefik
spec:
  rules:
  - host: k8s.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web-app-service
            port:
              number: 80

Deploy the ingress router:

kubectl apply -f ingress.yaml

Step 5: Installing Helm 3 Package Manager for Kubernetes

Helm simplifies deploying complex enterprise applications (such as Redis, PostgreSQL, WordPress, or Prometheus) using pre-packaged charts:

# Download and install Helm 3 binary
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

# Add Bitnami official chart repository
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

# Install a production-ready Redis cluster via Helm in 10 seconds
helm install my-redis bitnami/redis --set auth.password="StrongRedisPass2026!"

Standard Kubernetes (K8s) vs Lightweight K3s Benchmark

Feature / Metric Lightweight K3s (Rancher) Standard Kubernetes (K8s / EKS)
Idle RAM Consumption ~350 MB to 512 MB ~3.5 GB to 6.0 GB
Installation Complexity 1 Single Command (30 seconds) Multi-step manual node bootstrapping
Included Ingress & Storage Pre-packaged Traefik & Local Path Requires separate manual installs

Deploying Persistent Volume Storage with Local-Path Provisioner

K3s includes Rancher’s lightweight local-path storage class by default, allowing containerized stateful workloads (such as MySQL, PostgreSQL, or Redis) to dynamically request persistent host disk storage without requiring complex external SAN/NFS arrays:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: database-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 10Gi

Automating Application Scaling with Horizontal Pod Autoscaler (HPA)

K3s includes the lightweight metrics-server out of the box. Automatically scale pod replicas up to 10 when CPU utilization exceeds 75%:

# Enable Horizontal Pod Autoscaling on web-app-deployment
kubectl autoscale deployment web-app-deployment --cpu-percent=75 --min=2 --max=10

# Inspect active autoscaler metrics
kubectl get hpa

Essential K3s Operational Commands Cheat Sheet

  • kubectl get pods -A -o wide: View all running pods, container IPs, and host node bindings.
  • kubectl logs -f deployment/web-app-deployment: Stream real-time container log output across all pod replicas.
  • kubectl top nodes && kubectl top pods: Inspect exact real-time CPU and memory consumption per pod.

Deploy High-Performance Kubernetes Nodes on CpanelFree

Orchestrate microservices and container clusters with dedicated enterprise CPU cores, NVMe storage, and 100% free hosting options.

Get Free Cloud Hosting Today →

Deploy Fast, Reliable Web Hosting on CpanelFree

Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.

Claim Free Hosting Account

About the author

Blog

DevOps architect and Linux sysadmin specializing in server hardening, OpenLiteSpeed performance optimization, and free cloud hosting infrastructure.

Leave a Comment