How To Install Kubernetes On A Raspberry Pi

So, you want to get into the world of containerized computing and all the advantages that come with it? 

If that’s the case then you’ve probably already heard about Kubernetes and the wonders it can do, but if you don’t know how to install Kubernetes on Raspberry Pi then don’t worry! I’m here to guide you through the process every step of the way.

Let’s get into it!

What Even Is Kubernetes?

Author, and technology evangelist at Red Hat, Gordon Haff describes Kubernetes as:

“… an open source platform that automates Linux container operations. It eliminates many of the manual processes involved in deploying and scaling containerized applications.”

In other words, you can cluster together groups of hosts running Linux containers, and Kubernetes helps you easily and efficiently manage those clusters.

Anything that helps you stay on top of your projects as they become more complicated is good news in our books, and Kubernetes is winning over the hearts and minds of IT professionals and hobbyists around the world.

kubernetes on a raspberry pi

What You Need To Run Kubernetes On A Raspberry Pi

First things first, to install Kubernetes on Raspberry Pi, you’ll need a few things before getting started:

  1. A Raspberry Pi with at least 2GB RAM
  2. USB power supply for your Raspberry Pi device
  3. An SD card with a storage capacity of at least 8GB or more
  4. Docker Desktop if you’re planning on building your own images
  5. Some basic command line know-how

Top Tip: Kubernetes writes to SD cards a lot and can increase the chances of killing a card, so it’s best to buy multiple smaller cards than just a few excessively large ones.

First You Need To Flash The Initial OS

Once you’ve got everything ready, the first step is to flash the initial OS image onto your Pi’s SD card

This can be done by flashing a standard ISO image file like the official Ubuntu ISO file for Pi on your device through Etcher.io or Raspberry Pi Imager

You can also use the desktop version of Ubuntu if you have a USB keyboard and an HDMI cable lying around to pair up your Pi with desktop peripherals but for the purpose of this post, we’ll be using Ubuntu Server for installing Kubernetes on Raspberry Pi.

  • For Ubuntu Pi, add a blank file with the name to the directory of your memory card to enable SSH. 
  • Alternatively for the Desktop variant of Ubuntu, connect your device to a monitor and keyboard and then allow ssh using the following steps:
  • Update packages using the commands
  • Install OpenSSH
  • Enable SSH
  • Place the SD card in the SD slot on the Raspberry Pi, then turn on your devices
  • Then, using the nmap code or the router’s administrative console, find out the IP addresses of all Raspberry Pis. To prevent IP addresses from changing in the future due to restarts, it is advised to set the router to reserve the IP address for each Raspberry Pi.
  • Lastly, use the default password to ssh into your Raspberry Pi devices and replace the default password with a safer one of your chosing.

Install And Configure K3

In this section, we’ll be using the original ansible template and a few extra playbooks to configure and install k3. So be sure to clone the following repositories before getting started:

Ansible Playbook – k3

Ansible Playbook – Pi Configuration

Prepare Docker Container

As a prerequisite you’ll also need to download and run docker. Follow the steps outlined below to get started:

  • Start the Docker container by opening up a terminal window and cd into the directory.
  • Make a copy of the as
  • Initiate kube-tools by running the following code
  • Then approve the container by using the following command
  • After validating the container, SSH into it by running
  • Finally, validate ansible

Setup Playbooks

Follow the steps outlined below to set up your playbooks:

  • cd into the copied ansible repository 
  • Edit with the IP addresses you’ve found previously using the nmap command above and the Pis’ preferred hostname in the format shown below.
  • cd into the copied k3 repository
  • Make a new directory
  • Add the IP addresses acquired above to in the following structure:
  • Finally, set ansible_user to in.

Create RSA Key

  • cd into the copied ansible repository
  • Create RSA key by executing the following playbook
  • Alternatively, you can generate RSA key manually by executing the following commands:
  • Run the following playbook to duplicate RSA keys to all Pi devices
  • Alternatively, the following command can be used to manually copy each Pi’s RSA key as well

Update Host Name

  • Run the playbook below to change the hostnames on your Raspberry Pi devices
  • Hostnames can also be updated manually by individually ssh’ing into every Pi device and editing the names in and , and then performing the command

Install Kubernetes On Raspberry Pi

  • cd into the copied k3 repository
  • Start the cluster’s provisioning using the following code
  • Get kube config from the master node
  • Then validate the nodes by running

How To Install Kubernetes Dashboard

The Kubernetes Dash is a web-based, general-purpose UI for controlling Kubernetes clusters. Here’s how you can install it on your Pi devices:

  • cd into directory
  • Initiate the dashboard from the official source
  • Confirm the pod status 
  • Create a read-only and an admin user for Kubernetes dashboard by typing the following commands
  • Get secret for dashboard admin user by executing the following lines of code
  • Launch proxy for linking to the dashboard
  • Go to the following URL to open the Kubernetes dashboard in your web browser.

Source: Kubernetes.com

  • Now the kubernetes dashboard and cluster should be up and running in your Pi device ready to execute applications

Top Tip: If you ever need to delete the kubernetes dashboard for any reason, open a terminal window and cd into the directory, and run the following command:

buy raspberry pi accessories

Example Kubernetes Cluster Uses For The Raspberry Pi

Once you’ve got a Kubernetes cluster up and running on your Raspberry Pi devices, there are plenty of different applications that you can use it for. 

From setting up distributed systems to creating IoT networks, and even hosting web services, the possibilities are quite literally endless.

Here are a few amazing examples of some of the most popular Raspberry Pi Kubernetes cluster uses:

  • Building your own homelab and hosting your private GitHub system
  • Self-hosting your private cloud
  • Using it as a NAS storage solution at home or at the office
  • Home automation
  • Hosting your own web server
  • Hosting your Minecraft game server

So, what are you waiting for? Start building your own Kubernetes cluster today!

If you’re someone who is more of a visual learner, make sure you check out this video from Andrew Malkov for his run down on how to install Kubernetes on a Raspberry Pi.

Erik D

Leave a Comment

Your email address will not be published. Required fields are marked *