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.
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:
- A Raspberry Pi with at least 2GB RAM
- USB power supply for your Raspberry Pi device
- An SD card with a storage capacity of at least 8GB or more
- Docker Desktop if you’re planning on building your own images
- 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. However, for the purpose of this post, we’ll be focusing on using Ubuntu Server for installing Kubernetes on Raspberry Pi.
For Ubuntu Server on Raspberry Pi, after flashing your SD card, enable SSH by adding a blank file named ssh
(without any extension) to the root directory of your SD card. This step is crucial as it allows you to connect to your Raspberry Pi remotely without requiring a monitor and keyboard for initial setup.
Alternatively, for the Desktop variant of Ubuntu, if you prefer a direct setup or need to initially configure your system with a GUI, connect your device to a monitor and keyboard. Then, enable SSH through the terminal or settings menu by following the steps provided in the Ubuntu documentation or settings interface to allow remote connections.
- 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 – 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:
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.
- How To Download and Install iTunes on Ubuntu - August 1, 2024
- Easy Guide on How To Install Docker on Raspberry Pi - July 24, 2024
- How to Install UFW Firewall on Your Raspberry Pi - July 14, 2024
“For Ubuntu Pi, add a blank file with the name to the directory of your memory card to enable SSH. ”
What name for the blank file?
So sorry that I missed that in our article! The name of the file should be
ssh
. I have fixed that in the article now. Thanks for bringing it to my attention 🙂