Deploy Kubernetes with Lens on a VPS
Set up a lightweight K3s cluster on your RamNode VPS and manage it visually with Lens Desktop — real-time metrics, Helm chart management, and workload control from an intuitive GUI.
At a Glance
| Tools | K3s + Lens Desktop (or Freelens) |
| Recommended Plan | 2 GB RAM dev/test, 4 GB+ production |
| OS | Ubuntu 24.04 LTS |
| Key Feature | Visual Kubernetes management with real-time metrics |
| Estimated Setup Time | 30–45 minutes |
Prerequisites
- A RamNode VPS with at least 2 GB RAM (Ubuntu 24.04 LTS)
- SSH key-based authentication configured
- A local workstation running macOS, Windows, or Linux
- A domain name (optional, recommended for production)
Provision and Prepare Your VPS
SSH in, update the system, and create a non-root user:
ssh root@YOUR_SERVER_IP
apt update && apt upgrade -y
adduser k8sadmin
usermod -aG sudo k8sadminSet Up SSH Key Auth
ssh-copy-id k8sadmin@YOUR_SERVER_IPsudo sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart sshdsudo hostnamectl set-hostname k3s-node
echo "127.0.1.1 k3s-node" | sudo tee -a /etc/hostsInstall K3s
K3s provides a single-binary Kubernetes installation including kubectl, containerd, Traefik, CoreDNS, and metrics-server.
curl -sfL https://get.k3s.io | sh -sudo systemctl status k3s
sudo kubectl get nodes
sudo kubectl get pods -AExpected output: Your node should show Ready status with system pods for coredns, traefik, metrics-server, and local-path-provisioner all Running.
Configure the Firewall
sudo apt install ufw -y
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 6443/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 8472/udp
sudo ufw allow 10250/tcp
sudo ufw enableRestrict API by IP (Recommended)
sudo ufw delete allow 6443/tcp
sudo ufw allow from YOUR_LOCAL_IP to any port 6443 proto tcpSet Up Remote Kubeconfig
Copy the K3s kubeconfig to your local machine and update the server address:
mkdir -p ~/.kube
scp k8sadmin@YOUR_SERVER_IP:/etc/rancher/k3s/k3s.yaml ~/.kube/ramnode-k3s.yamlIf you get a permission error:
sudo cp /etc/rancher/k3s/k3s.yaml /home/k8sadmin/k3s.yaml
sudo chown k8sadmin:k8sadmin /home/k8sadmin/k3s.yamlsed -i '' 's/127.0.0.1/YOUR_SERVER_IP/g' ~/.kube/ramnode-k3s.yamlsed -i 's/127.0.0.1/YOUR_SERVER_IP/g' ~/.kube/ramnode-k3s.yamlKUBECONFIG=~/.kube/ramnode-k3s.yaml kubectl get nodesInstall Lens Desktop
Download Lens from k8slens.dev or use a package manager:
brew install --cask lenscurl -fsSL https://downloads.k8slens.dev/keys/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/lens-archive-keyring.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/lens-archive-keyring.gpg] https://downloads.k8slens.dev/apt/debian stable main" | sudo tee /etc/apt/sources.list.d/lens.list > /dev/null
sudo apt update
sudo apt install lens-desktopOpen-Source Alternative: Freelens is a community-maintained fork providing core Lens functionality without a commercial license.
Connect Lens to Your K3s Cluster
In Lens Desktop:
- Click Catalog → + → Add from kubeconfig file
- Browse to
~/.kube/ramnode-k3s.yaml - Select the cluster context and click Add Cluster
Rename Context (Optional)
contexts:
- context:
cluster: ramnode-k3s
user: ramnode-k3s-admin
name: ramnode-k3s
clusters:
- cluster:
server: https://YOUR_SERVER_IP:6443
certificate-authority-data: <base64-data>
name: ramnode-k3sEnable Metrics and Monitoring
K3s ships with metrics-server pre-installed:
sudo kubectl top nodes
sudo kubectl top pods -AEnable Lens Built-In Prometheus (Optional)
Right-click the cluster → Settings → Metrics → choose Lens as the Prometheus source. Lens deploys a lightweight Prometheus into the lens-metrics namespace.
Resource note: The built-in Prometheus adds ~200–300 MB RAM overhead. On a 2 GB plan, consider using the default metrics-server instead.
Deploy a Sample Application
kubectl create namespace demo
kubectl -n demo create deployment nginx --image=nginx:latest --replicas=2
kubectl -n demo expose deployment nginx --port=80 --type=ClusterIPIn Lens, navigate to Workloads → Deployments to see the nginx deployment with 2/2 pods ready.
Create an Ingress (Optional)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
namespace: demo
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
rules:
- host: demo.yourdomain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80kubectl apply -f nginx-ingress.yamlManaging Workloads Through Lens
| Feature | Description |
|---|---|
| Log Streaming | Click any pod → Logs tab. Filter by container, search, download. |
| Shell Access | Right-click pod → Shell. Interactive terminal inside the container. |
| Resource Editing | Double-click any resource to edit YAML and apply directly. |
| Scaling | Right-click deployment → Scale to adjust replicas in real time. |
| Rolling Restarts | Right-click deployment → Restart to trigger a rolling restart. |
Helm Chart Management
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm repo updateIn Lens: Helm → Charts to browse, install, and configure charts. Helm → Releases to upgrade, rollback, or uninstall.
Security Hardening
TLS SANs for API Server
curl -sfL https://get.k3s.io | sh -s - --tls-san YOUR_SERVER_IP --tls-san k3s.yourdomain.comRestrict Kubeconfig Permissions
chmod 600 ~/.kube/ramnode-k3s.yamlSSH Tunnel (Alternative to Exposing 6443)
ssh -L 6443:127.0.0.1:6443 k8sadmin@YOUR_SERVER_IP -NThen update your kubeconfig to point to https://127.0.0.1:6443. Keeps the API completely off the public internet.
Backup and Recovery
sudo k3s etcd-snapshot save --name pre-upgrade-snapshotAutomated Daily Snapshots
0 2 * * * /usr/local/bin/k3s etcd-snapshot save --name daily-$(date +\%Y\%m\%d)Snapshots stored in /var/lib/rancher/k3s/server/db/snapshots/.
Restore from Snapshot
sudo systemctl stop k3s
sudo k3s server --cluster-reset --cluster-reset-restore-path=/var/lib/rancher/k3s/server/db/snapshots/SNAPSHOT_NAME
sudo systemctl start k3sTroubleshooting
- Lens cannot connect — Verify port 6443 is open:
sudo ufw status | grep 6443. Test withcurl -k https://YOUR_SERVER_IP:6443/version. - Pods stuck in Pending — Check resources:
kubectl describe node k3s-nodeandkubectl top nodes. - Metrics not showing — Confirm metrics-server is running:
kubectl get pods -n kube-system | grep metrics. Wait 60s after connection. - K3s fails to start — Check logs:
sudo journalctl -u k3s -f. Verify at least 512 MB RAM available. - High memory usage — Disable Lens Prometheus stack and rely on built-in metrics-server, or upgrade your VPS plan.
