Setting Up a Kubernetes Cluster on Raspberry Pi

May 15, 2025
Kubernetes
Raspberry Pi
DevOps
Homelab

Setting up a Kubernetes cluster on Raspberry Pi devices is an excellent way to learn Kubernetes concepts without breaking the bank. In this guide, I'll walk you through the entire process from hardware setup to deploying your first application.

Hardware Requirements

  • 3-4 Raspberry Pi 4 devices (at least 4GB RAM each)
  • MicroSD cards (at least 32GB)
  • Network switch
  • Power supply for each Pi

Operating System Installation

I recommend using Ubuntu Server 20.04 LTS for Raspberry Pi. It's stable and well-supported for Kubernetes deployments.

Network Configuration

For a production-like environment, it's best to configure static IP addresses for all nodes. I use pfSense for DHCP management and static IP assignment.

Installing K3s

K3s is a lightweight Kubernetes distribution perfect for resource-constrained environments like Raspberry Pi. Here's how to install it on your master node:

curl -sfL https://get.k3s.io | sh -

For worker nodes, you'll need to use the token from your master node:

curl -sfL https://get.k3s.io | K3S_URL=https://master-ip:6443 K3S_TOKEN=your-token sh -

Automating with Ansible

To make the setup process repeatable and manageable, I created Ansible playbooks for provisioning and configuration across all nodes.

Setting Up Traefik

Traefik serves as a reverse proxy and dynamic load balancer to manage internal routing and service discovery within the cluster.

Deploying Your First Application

With the cluster up and running, you can now deploy applications using kubectl or Helm charts.

Monitoring Your Cluster

I recommend setting up Prometheus and Grafana for monitoring your cluster's health and performance.

Conclusion

Building a Kubernetes cluster with Raspberry Pi devices provides hands-on experience with systems administration, infrastructure as code, container networking, and service orchestration in a production-like environment.