k3s is a lightweight Kubernetes distribution developed by Rancher Labs. It is designed for resource-constrained environments like IoT devices, home labs, or small-scale deployments. This document covers its key features and installation steps on both Raspberry Pi and multi-node clusters.
Ensure your system is up to date:
sudo apt-get update && sudo apt-get upgrade -y
curl -sfL https://get.k3s.io | sh -
This installs k3s as a service and sets up a single-node cluster.
sudo kubectl get nodes
Your Raspberry Pi should be listed as Ready .
kubectl create deployment nginx-test --image=nginx
kubectl expose deployment nginx-test --type=NodePort --port=80
Access nginx via your Raspberry Pi’s IP address.
curl -sfL https://get.k3s.io | sh -
Retrieve the token for joining worker nodes:
cat /var/lib/rancher/k3s/server/node-token
curl -sfL https://get.k3s.io | K3S_URL="https://YOUR_K3S_SERVER_IP:6443" K3S_TOKEN="YOUR_NODE_TOKEN" sh -
Replace the placeholders with the actual server IP and token.
kubectl get nodes
All nodes should appear with the status Ready .
Use kubectl
or Helm to deploy applications.
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-k3s
spec:
replicas: 1
selector:
matchLabels:
app: hello-k3s
template:
metadata:
labels:
app: hello-k3s
spec:
containers:
- name: hello-k3s
image: nginx
ports:
- containerPort: 80
kubectl apply -f deployment.yaml
kubectl expose deployment hello-k3s --type=NodePort --port=80
k3s makes it easier to deploy Kubernetes in constrained environments while retaining compatibility with standard Kubernetes features. By following these steps, you can set up a k3s cluster for learning, development, or small-scale production use.