DevOps & Containers
What Is Kubernetes? A Clear Introduction and k3s on a VPS
By NileVPS Team · Published · 4 min read
اقرأ المقال بالعربيContainers made it easy to package an application with everything it needs. Running a handful of containers on one server is simple; running dozens across several servers, keeping them healthy, updating them without downtime and routing traffic to them is not. Kubernetes is the system most teams use for that job. This guide explains what Kubernetes does in plain terms, introduces its core concepts, helps you decide whether you need it, and walks through installing k3s, a lightweight Kubernetes distribution, on a VPS.
What Kubernetes Does
Kubernetes (often written K8s) is an open-source container orchestrator, originally developed at Google and now maintained by the Cloud Native Computing Foundation. You describe what you want to run in YAML files, and Kubernetes makes it happen and keeps it that way. In practice it handles:
- Scheduling: placing containers on servers that have enough CPU and memory.
- Self-healing: restarting crashed containers and replacing those on failed nodes.
- Rolling updates and rollbacks: replacing versions gradually.
- Service discovery and load balancing: giving each group of containers a stable name and address.
- Configuration and secrets: injecting settings without rebuilding images.
- Scaling: changing the number of replicas by command or automatically.
Core Concepts
| Object | Purpose |
|---|---|
| Node | A server (VPS or physical) that runs workloads |
| Pod | The smallest unit: one or more containers sharing a network address |
| Deployment | Keeps a set number of identical pods running and manages updates |
| Service | A stable virtual IP and DNS name in front of a group of pods |
| Ingress | HTTP routing from outside the cluster to Services, by host and path |
| ConfigMap / Secret | Configuration values and sensitive data for pods |
| PersistentVolume | Storage that outlives individual pods |
| Namespace | A way to group and isolate resources |
A cluster has a control plane (the API server, scheduler, controller manager and the etcd database) and worker nodes running the kubelet and a container runtime. You talk to the control plane with the kubectl command line tool.
Do You Actually Need Kubernetes?
Kubernetes is powerful, but it adds real complexity. Be honest about your situation:
- One app, one server, modest traffic: Docker Compose behind Nginx is usually simpler and enough. Start with Docker explained for beginners.
- Several services, frequent deployments, a need for self-healing or multiple servers: Kubernetes starts to pay off.
- Learning for your career: a small cluster on a VPS is an excellent, affordable lab.
Why k3s Fits a VPS
k3s is a certified Kubernetes distribution packaged as a single binary. It replaces etcd with an embedded SQLite datastore by default for single-server setups (embedded etcd is available for multi-server high availability) and ships with useful defaults: containerd, the Flannel network plugin, CoreDNS, the Traefik ingress controller, a simple service load balancer and a local-path storage provisioner. It uses less memory than a full upstream installation. A server node can start with modest RAM, but plan for at least 2 GB of RAM and 2 vCPUs if you want room for real workloads.
Installing k3s on a VPS
Use a fresh Ubuntu LTS or Debian server. First, update it:
sudo apt update && sudo apt upgrade -yInstall k3s with the official script:
curl -sfL https://get.k3s.io | sh -The script installs k3s as a systemd service. Check it:
sudo systemctl status k3s
sudo k3s kubectl get nodesThe kubeconfig file is at /etc/rancher/k3s/k3s.yaml. To use kubectl as a normal user:
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
chmod 600 ~/.kube/config
kubectl get pods -AAdding Worker Nodes
On the server, read the join token:
sudo cat /var/lib/rancher/k3s/server/node-tokenOn each additional VPS, run:
curl -sfL https://get.k3s.io | K3S_URL=https://<server-ip>:6443 K3S_TOKEN=<token> sh -Allow the required ports between nodes only: TCP 6443 for the API server, UDP 8472 for Flannel VXLAN and TCP 10250 for the kubelet. Do not expose these ports to the whole internet; restrict them with a cloud firewall or ufw.
Deploying Your First App
Create a file named web.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.27
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- port: 80
targetPort: 80Apply it and check the result:
kubectl apply -f web.yaml
kubectl get deploy,pods,svc
kubectl scale deployment web --replicas=3
kubectl rollout status deployment webAdd an Ingress pointing your domain at the web Service, and Traefik will route HTTP traffic to it.
Day-2 Tips
- Back up
/var/lib/rancher/k3s/server/(or use thek3s etcd-snapshotcommands when running embedded etcd). - Set CPU and memory requests and limits on every container so one app cannot starve others.
- Take a VPS snapshot before upgrading k3s.
- Learn how pod networking works in our guide to Kubernetes CNI.
FAQ
Is k3s real Kubernetes?
Yes. k3s is a CNCF-certified Kubernetes distribution, so standard manifests, Helm charts and kubectl work as expected. It mainly differs in packaging and defaults, not in the API.
Can I run Kubernetes on a single VPS?
Yes. A single k3s node runs both the control plane and workloads, which is fine for learning, staging and small projects. You lose protection against that server failing, so keep backups and snapshots.
What is the difference between Docker and Kubernetes?
Docker builds and runs containers on one machine. Kubernetes orchestrates containers across many machines, handling scheduling, healing, scaling and networking. Kubernetes runs containers built with Docker through a runtime such as containerd.