Learn how to build your own Kubernetes Homelab with Raspberry Pi
I recently built a tool called k3sup or ('ketchup') which installs Kubernetes on any PC, VM or Raspberry Pi using k3s from Rancher. k3s is a super light-weight Kubernetes distribution perfect for the edge, IoT and embedded systems.
In this post I'll share my new Insiders video with you "Kubernetes Homelab with Raspberry Pi 4" and the tools and links you need to try everything out at home.
k3sup started off as a wrapper for the k3s installation scripts, but after feedback from the community, it quickly gained a command to build clusters.
The next step for k3sup was the ability to install projects built for Kubernetes with the k3sup app install
command. This got so popular, with 40 apps that a new CLI was spun out called arkade.
In this video I'll show you how to use a single binary to setup a Kubernetes cluster on your Raspberry Pi 4, how to install OpenFaaS, and how to get a public IP on the Internet for your RPi homelab.
You may also like: Expose your local OpenFaaS functions to the Internet.
Updated: Feb 2021 - "k3sup app install" is now its own CLI called arkade, plus additional syntax was added for the inlets-operator.
Watch the video
Since the video was published, inlets-operator now requires a license key for inlets PRO. The "app" command in k3sup moved to the new arkade CLI. Everything else should work as described in the video.
k3sup
reference
Here's a quick reference for k3sup, that you can also find on the project homepage.
You can use k3sup with any VM or PC, you just need SSH access. It also works with ARMHF (Raspberry Pi) and ARM64 (Equinix Metal/AWS Graviton).
-
Get the tool or update
curl -SLsf https://get.k3sup.dev | sudo sh
-
Start a new cluster
k3sup install --ip $SERVER_IP --user pi
-
Join an agent/worker into the cluster
k3sup join --ip $AGENT_IP --server-ip $SERVER_IP --user pi
-
Install OpenFaaS on ARMHF, ARM64 or a PC/VM
arkade install openfaas
k3sup
actually works on any Kubernetes cluster, so if you like the tool, you can use it to install OpenFaaS.
inlets-operator
The other part of the video showed the inlets-operator. It gave us a public IP for our cluster within a matter of seconds.
Having a public IP isn't strictly necessary, but it can be a great way to share your work and integrate with third-party systems and event-sources like GitHub, Strava, and Stripe.
There's simply three steps needed to get public IPs for your local cluster.
Note these steps may have changed a little since the original video was rceorded.
The Operator obtains a public IP for you by creating a low-cost VM on DigitalOcean, Equinix Metal and around half a dozen other providers are also supported. The DigitalOcean Droplet costs around 5 USD / mo.
See instructions for other clouds here: inlets-operator reference
-
Create an API key on your DigitalOcean account
Save it as
~/Downloads/do-access-token
-
Get an inlets-pro trial, or purchase a personal license at inlets.dev.
Save your JWT to
$HOME/.inlets/LICENSE
. -
Install the inlets-operator
curl -sSLf https://get.arkade.dev | sudo sh arkade install inlets-operator \ --token-file=$HOME/Downloads/do-access-token \ --license-file=$HOME/.inlets/LICENSE
-
Install an Ingress Controller
If you're using k3s, you should have Traefik 1.0 installed, otherwise, install ingress-nginx with:
arkade install ingress-nginx
Look up the public IP address of ingress-nginx or traefik as created by the inlets-operator:
# For traefik kubectl get svc/traefik -n kube-system -o wide # For ingress-nginx kubectl get svc -n default -o wide
Create a DNS A record from the IP address to your domain for the OpenFaaS gateway such as
openfaas.example.com
-
Install cert-manager
cert-manager will obtain free TLS certificates for your HTTP services like the OpenFaaS gateway
-
Get a certifcate for the OpenFaaS gateway
export DOMAIN="openfaas.example.com" arkade install openfaas-ingress --domain $DOMAIN --email webmaster@$DOMAIN
In a short period of time, you'll be able to access your OpenFaaS UI and run
faas-cli login
with the URLhttps://openfaas.example.com
CNCF Landscape and new logo
Oh, and here's a small announcement I'm happy to share:
Really excited to see @inletsdev growing up and leaving home with its own @github org and a place on the @CloudNativeFdn Landscape.
— Alex Ellis (@alexellisuk) October 16, 2019
A big thank you to @iboonox for providing a logo. Website will be coming soon.
Check it out, give it a ⭐️https://t.co/5pPjk2MlpH pic.twitter.com/NuDqCgkN5g
The inlets project now has its own GitHub organisation: github.com/inlets/inlets and is listed on the CNCF Landscape
Get the materials
You may already have the parts, but if you don't, feel free to check out these affiliate links on Amazon. If you're in the UK and in Europe, you may prefer to use Pimoroni.
- RPi4 with 4 GB RAM
- Wrap-around case with built-in aluminium heatsink
- 32GB Sandisk SD card
Take it further
Are there other apps or helm charts you'd like to see in arkade
? Raise an issue, or propose it via OpenFaaS Slack
Want to be the first to get exclusive content from my channel and open source projects? This video was released a week early for my Insiders.
Become an Insider via GitHub Sponsors
Related posts:
- Multi-master HA Kubernetes in < 5 minutes
- Cooling off your Raspberry Pi 4
- Will it cluster? k3s on RPi
- Expose your local OpenFaaS functions to the Internet
Tools: