Table of Contents
Kubernetes is the industry standard for container orchestration, and K3s makes it possible to run a fully functional cluster on Raspberry Pi hardware. Whether you are learning for career growth or building a production-grade home lab, a Pi-based K3s cluster is the most cost-effective way to master Kubernetes in India.
What is K3s and Why Use It on Raspberry Pi
K3s is a lightweight, certified Kubernetes distribution designed for resource-constrained environments. Created by Rancher Labs, it strips out cloud-provider-specific code and replaces etcd with SQLite, reducing the binary to under 100MB.
- Memory footprint: ~512MB RAM for the server node (vs 2GB+ for full K8s)
- Single binary: One ~60MB binary handles everything
- ARM native: First-class ARM64 and ARMv7 support
- Batteries included: Traefik ingress, CoreDNS, and Flannel CNI pre-configured
- Production ready: CNCF certified Kubernetes conformant
Hardware Setup for a Pi Cluster
A minimal cluster needs at least 2 Pis; 3-4 is ideal for learning high availability:
| Component | Quantity | Notes |
|---|---|---|
| Raspberry Pi 4/5 (4GB+) | 3-4 | 8GB for server node recommended |
| MicroSD cards or NVMe SSDs | 3-4 | 32GB+ each, SSD preferred |
| Ethernet cables | 3-4 | Gigabit for reliable networking |
| Network switch | 1 | Gigabit, 5+ ports |
| USB-C power supplies | 3-4 | 5V 3A per Pi (or PoE HATs) |
| Cluster case/rack | 1 | Optional but keeps things tidy |
Cluster Components on Zbotic.in
Installing K3s on the Master Node
Start with the server (master) node. Ensure each Pi has a unique hostname and static IP:
# Set hostname on the master node
sudo hostnamectl set-hostname k3s-master
# Assign a static IP (edit dhcpcd.conf or use NetworkManager)
# Example: 192.168.1.100 for master
# Enable cgroups (required for K3s)
# Edit /boot/firmware/cmdline.txt and add at the END of the line:
# cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
sudo nano /boot/firmware/cmdline.txt
sudo reboot
# Install K3s server
curl -sfL https://get.k3s.io | sh -
# Check the server status
sudo systemctl status k3s
sudo kubectl get nodes
# Get the node token (needed for workers)
sudo cat /var/lib/rancher/k3s/server/node-token
Joining Worker Nodes to the Cluster
# On each worker Pi, set a unique hostname:
sudo hostnamectl set-hostname k3s-worker-1 # or worker-2, worker-3
# Enable cgroups (same as master)
# Edit /boot/firmware/cmdline.txt, add:
# cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
sudo reboot
# Join the cluster (replace with your master IP and token)
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.1.100:6443
K3S_TOKEN="your-node-token-here" sh -
# Back on the master, verify all nodes:
sudo kubectl get nodes
# NAME STATUS ROLES AGE VERSION
# k3s-master Ready control-plane,master 10m v1.30.x+k3s1
# k3s-worker-1 Ready <none> 2m v1.30.x+k3s1
# k3s-worker-2 Ready <none> 1m v1.30.x+k3s1
Deploying Your First Application
# Create a deployment YAML
cat << 'EOF' > nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
resources:
limits:
memory: "128Mi"
cpu: "250m"
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80
targetPort: 80
nodePort: 30080
EOF
# Deploy it
sudo kubectl apply -f nginx-deployment.yaml
# Check the deployment
sudo kubectl get pods -o wide
sudo kubectl get services
# Access at http://<any-node-ip>:30080
Monitoring with kubectl and Dashboard
# Install the Kubernetes Dashboard
GITHUB_URL=https://github.com/kubernetes/dashboard/releases
VERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S
$GITHUB_URL/latest -o /dev/null | sed -e 's|.*/||')
sudo kubectl create -f
https://raw.githubusercontent.com/kubernetes/dashboard/${VERSION_KUBE_DASHBOARD}/aio/deploy/recommended.yaml
# Create admin user for dashboard
cat << 'EOF' | sudo kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
EOF
# Get the login token
sudo kubectl -n kubernetes-dashboard create token admin-user
# Access dashboard via port-forward
sudo kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 8443:443 --address=0.0.0.0
Persistent Storage and Networking
K3s includes local-path-provisioner for persistent volumes:
# Local path storage class is the default in K3s
sudo kubectl get storageclass
# NAME PROVISIONER AGE
# local-path (default) rancher.io/local-path 30m
# For NFS shared storage across nodes:
sudo apt install nfs-kernel-server # On one Pi
sudo mkdir -p /srv/nfs/k3s
echo "/srv/nfs/k3s *(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports
sudo exportfs -ra
# Useful networking commands
sudo kubectl get ingress
sudo kubectl get endpoints
sudo kubectl describe service nginx-service
Frequently Asked Questions
How many Raspberry Pis do I need for a K3s cluster?
Minimum 2 (1 server + 1 worker), but 3 is recommended. For high availability, use 3 server nodes with an embedded etcd cluster. A 4-node cluster (1 server + 3 workers) is ideal for learning.
Can I run K3s on Raspberry Pi 3?
Technically yes, but not recommended. The Pi 3 has only 1GB RAM, which barely covers K3s server requirements. Worker nodes on Pi 3 can run a few lightweight pods. Pi 4 with 4GB+ is the practical minimum.
What is the cost of building a Raspberry Pi Kubernetes cluster in India?
A 3-node cluster costs approximately ₹15,000-25,000 depending on Pi model and accessories. This includes 3x Pi 4 (4GB), cases, SD cards, ethernet cables, and a switch. Significantly cheaper than cloud Kubernetes.
K3s vs MicroK8s vs full Kubernetes for Raspberry Pi?
K3s is the best choice for Pi clusters due to lowest resource usage. MicroK8s works well for single-node setups. Full Kubernetes (kubeadm) requires 2GB+ RAM per node and is overkill for Pi.
Can I use WiFi instead of Ethernet for the cluster?
WiFi works but is unreliable for Kubernetes. Cluster communication is latency-sensitive, and WiFi adds jitter. Always use Ethernet for the cluster network. WiFi can be used for external access.
{“@context”: “https://schema.org”, “@type”: “FAQPage”, “mainEntity”: [{“@type”: “Question”, “name”: “How many Raspberry Pis do I need for a K3s cluster?”, “acceptedAnswer”: {“@type”: “Answer”, “text”: “Minimum 2 (1 server + 1 worker), but 3 is recommended. For high availability, use 3 server nodes with an embedded etcd cluster. A 4-node cluster (1 server + 3 workers) is ideal for learning.”}}, {“@type”: “Question”, “name”: “Can I run K3s on Raspberry Pi 3?”, “acceptedAnswer”: {“@type”: “Answer”, “text”: “Technically yes, but not recommended. The Pi 3 has only 1GB RAM, which barely covers K3s server requirements. Worker nodes on Pi 3 can run a few lightweight pods. Pi 4 with 4GB+ is the practical minimum.”}}, {“@type”: “Question”, “name”: “What is the cost of building a Raspberry Pi Kubernetes cluster in India?”, “acceptedAnswer”: {“@type”: “Answer”, “text”: “A 3-node cluster costs approximately u20b915,000-25,000 depending on Pi model and accessories. This includes 3x Pi 4 (4GB), cases, SD cards, ethernet cables, and a switch. Significantly cheaper than cloud Kubernetes.”}}, {“@type”: “Question”, “name”: “K3s vs MicroK8s vs full Kubernetes for Raspberry Pi?”, “acceptedAnswer”: {“@type”: “Answer”, “text”: “K3s is the best choice for Pi clusters due to lowest resource usage. MicroK8s works well for single-node setups. Full Kubernetes (kubeadm) requires 2GB+ RAM per node and is overkill for Pi.”}}, {“@type”: “Question”, “name”: “Can I use WiFi instead of Ethernet for the cluster?”, “acceptedAnswer”: {“@type”: “Answer”, “text”: “WiFi works but is unreliable for Kubernetes. Cluster communication is latency-sensitive, and WiFi adds jitter. Always use Ethernet for the cluster network. WiFi can be used for external access.”}}]}
Get All Your Raspberry Pi Components from Zbotic.in
India’s trusted store for genuine Raspberry Pi boards, HATs, accessories, and components. Fast shipping across India with expert support.
Add comment