Single and multi-node Kubernetes cluster setup with K3s, kubectl usage, creating deployments and services, application management with Helm. Kubernetes guide for VPS environments.
Kubernetes is the industry standard for container orchestration. However, a full Kubernetes installation can be resource-intensive and complex. K3s is a lightweight Kubernetes distribution developed by Rancher — it delivers all Kubernetes features in a single binary and works excellently in resource-constrained environments like VPS.
Why Choose K3s?
Feature
Full Kubernetes
K3s
Binary size
~500MB+
~100MB
Minimum RAM
2GB+
512MB
Setup time
30-60 min
5 min
Dependencies
Many
Minimal
Kubernetes compatibility
Full
Full
Production use
Yes
Yes
K3s is fully compatible with the Kubernetes API. kubectl, Helm, and other Kubernetes tools work seamlessly with K3s. It's ideal for small to medium production environments.
# Install K3s (server mode)
curl -sfL https://get.k3s.io | sh -
# Check service status after installation
systemctl status k3s
# Check cluster status
kubectl get nodes
# List all pods
kubectl get pods -A
Kubeconfig Setup
hljs bash
# Copy kubeconfig for kubectlmkdir -p ~/.kube
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
chmod 600 ~/.kube/config
# Set KUBECONFIG environment variableexport KUBECONFIG=~/.kube/config
echo'export KUBECONFIG=~/.kube/config' >> ~/.bashrc
# View cluster info
kubectl cluster-info
Multi-Node Cluster Setup
Master Node (Server)
hljs bash
# Install master node and save token
curl -sfL https://get.k3s.io | sh -
# Get node token (required for worker nodes)cat /var/lib/rancher/k3s/server/node-token
# Output: K10xxx...::server:yyy...
Worker Node (Agent)
hljs bash
# Join worker node to master
curl -sfL https://get.k3s.io | K3S_URL=https://MASTER_IP:6443 K3S_TOKEN=NODE_TOKEN sh -
# Verify worker joined on master
kubectl get nodes
# NAME STATUS ROLES AGE# master-node Ready control-plane,master 10m# worker-node1 Ready <none> 2m
Basic kubectl Commands
hljs bash
# List nodes
kubectl get nodes
kubectl get nodes -o wide # Detailed info# List pods
kubectl get pods
kubectl get pods -n kube-system # System pods
kubectl get pods -A # All namespaces# List deployments
kubectl get deployments
# List services
kubectl get services
# List namespaces
kubectl get namespaces
# View resource details
kubectl describe pod POD_NAME
kubectl describe node NODE_NAME
# View pod logs
kubectl logs POD_NAME
kubectl logs -f POD_NAME # Live logs# Run command in pod
kubectl exec -it POD_NAME -- /bin/bash
# Apply service
kubectl apply -f nginx-service.yaml
# Check service
kubectl get services
# Access via browser: http://SERVER_IP:30080
Namespace Management
hljs bash
# Create namespaces
kubectl create namespace production
kubectl create namespace staging
# Deploy to namespace
kubectl apply -f deployment.yaml -n production
# List resources in namespace
kubectl get all -n production
# Change default namespace
kubectl config set-context --current --namespace=production
K3s delivers the full power of Kubernetes with minimal resource usage. It's an ideal solution for production-grade container orchestration in VPS environments. With K3s on REXE servers, you can easily scale your applications, ensure high availability, and implement modern DevOps practices.
Frequently Asked Questions
What is the key difference between K3s and full Kubernetes?
K3s is a lightweight distribution fully compatible with the Kubernetes API. Differences: K3s is a single binary (~100MB), while full Kubernetes requires multiple components. K3s can use SQLite (instead of etcd), consumes less RAM (512MB vs 2GB+), and installs much faster. Both are suitable for production use.
Pods aren't starting in K3s, what should I do?
First check events with kubectl describe pod POD_NAME. Common issues: 1) Insufficient resources (check with kubectl describe node), 2) Image pull error (test with docker pull), 3) PVC can't bind (check with kubectl get pvc), 4) Missing ConfigMap/Secret. Also check application logs with kubectl logs POD_NAME.
How do I access my application from outside?
Three methods: 1) NodePort Service: opens a port between 30000-32767, accessed via IP:PORT directly. 2) LoadBalancer Service: works with Klipper LB in K3s. 3) Ingress Controller: provides domain-based access to multiple apps over a single IP (recommended). Traefik comes bundled with K3s by default.
How do I customize a Helm chart?
View default values with helm show values CHART_NAME. Create a values.yaml file for customization and use it with helm install -f values.yaml. Alternatively, pass individual values with --set key=value. Use helm upgrade to update an existing installation.
I can't add a worker node to the K3s cluster, why?
Check: 1) Verify port 6443 on master is reachable from worker (telnet MASTER_IP 6443), 2) Confirm NODE_TOKEN is correct (cat /var/lib/rancher/k3s/server/node-token), 3) Verify port 6443 is open in firewall, 4) Check k3s-agent service logs on worker (journalctl -u k3s-agent -f).