Blogs

How to Build a Kubernetes Server on a Raspberry Pi cluster Part 1

Matthew Caspento Matthew Caspento April 21st, 2022

This is a step-by-step guide to building a home server and host in Zaloni’s Data Governance platform, Arena.

Raspberry Pi

Use Case Overview:

This blog will serve as a tutorial and guide to building a home server for the minimum requirements a user would need to host in the Arena platform or with a Kubernetes cluster.

Some of the benefits of building a home server is that you can host small applications, create smart home applications, and even websites, but it’s important to ensure that you have a high upload speed to do that. Additionally, you may want to avoid the costs of using a cloud provider by using a home server. I know I’m guilty of forgetting to delete an instance and racking up quite the bill. In my case, I’m building a home server so I can practice not only my IT, but also my CloudOps skills. And the best part, I can destroy and create as much as my server can handle without worrying about the monthly cost.

If you ever watched the movie Flubber with Robin Williams, you know the movie starts with this opening scene where this rube-goldberg-like machine makes his breakfast every morning. When I was a kid I thought that was absolutely crazy, and when I grew up, I wanted something like that too. Well, I’ve grown up, and now, I want to fulfill my childhood dreams. I eventually will need to get a 3D printer, but we’ll save that for a future post.

I have a goal to create an environment so that when I have children, they will be able to engineer and create whatever they dream of. Having this guide to building a home server is a start to it and I welcome you to follow this engineering journey.

List of Requirements:

3 x Raspberry Pi 4 Model B 8GB | $82.84 | Find Here | 
2 x Cluster Case for Raspberry Pi(with fans)*| $11.27 | Find Here |
3 x Micro SD Cards 128Gb* | $21.79 | Find Here |
3 x Mini PoE Expansion HAT | $27.79 | Find Here |
1 x USB keyboard*
1 x HDMI to microHDMI cable*| $3.38 | Find Here
3 x Ethernet Cat6 cords* | $1.69 | Find Here | #EthernetCables.jpg
1 x TP-Link AC1900 Smart WiFi Router| $59.99 | Find Here |
1 x TP-link 5-Port Gigabit PoE Switch | $42.89 | Find Here |

*optional

Total cost may vary depending on the optional choices you make on this build*

Shipping prices are not included*

Total: $556.48

Having a home server to automate breakfast: Eggcellent

Building the Raspberry Pi Cluster:

You’re gonna want to start with building the cluster case. The build should take 30 mins.

WARNING: DO NOT BUILD OVER A CARPET.

These bolts are tiny! This warning was in every tutorial I followed. Unfortunately for me, I ignored the documentation and ended up taking a comb to my carpet as if I were one of the troopers in “Spaceballs” combing the desert.

You can follow along with the provided pictures to assemble the ClusterCase with Pi’s.

ClusterCase

You’re gonna want to make sure the round nuts are on top and not the bottom so the case does not slide around.

 

Raspberry Pi and ClusterCase

Add the first pi to the glass stand.

Raspberry Pi with closed ClusterCase

Add the new glass level, but this time, include the fan and attach it to the pi.

Raspberry Pi with fan attached.

Once you have the new level and have added it to the case, finish by attaching another raspberry pi to the case and the top level with the attached fan.

Once the case and Pis are set up, we move to the next step by installing the operating system. In this blog, we will be using Ubuntu.

First, you will want to download the Raspberry Pi Imager; you can go can use one of the following to do so:

$ sudo snap install rpi-imager
Raspberry Pi Imager Screenshot
Raspberry Pi Imager Screenshot

Reserving Static Addresses:

tp-link screenshot

Before we address the raspberry pi’s, you will need to set up the router and PoE switchboard to utilize the PoE HATS. If you don’t want to use the HATS, use the power supply plugs. Plugin the router to your ISP router that is already connected to the internet, find the connection, and connect to it. The next step is to go to the address http://tplinkwifi.net and create a new login to sign in. You can skip the quick setup and go to the console where you will find in the advanced settings and the network tab where we will do most of the editing.

To start, let’s first configure the LAN.

tp-link screenshot
LAN
Ip Address: 10.204.4.1
SubnetMask: 255.255.255.0

Next, if you go to the Internet tab, you will see a drop-down for the Internet Connection Type and choose Dynamic IP. Since you have connected the router to your ISP router, it dynamically sets the parameters requested.

With that step done, we will now focus on the DHCP server. Make sure that it is enabled as well as the Raspberry Pis being on and connected to the switchboard that’s connected to the router. Doing so the router will automatically identify the Raspberry Pis where you can see them in the DHCP Client list. Notice the MAC address as you will need that later to set the static Ip addresses for the Pi’s. But moving back to the top of the page. You can use this as an example on how it should look.

DCHP Server Screenshot

Once completed, you can check the internet connection by going to any website and making sure it loads.

Now to set the static Ip addresses, the part of the page Address Reservation is where we will assign the Ip address of the RaspberryPis:

Device Name| Mac Address| Reserved Ip Address|
Kube-master| R7–3J-95–8H-KL-Y2| 10.204.4.101|
Kube-worker-1| R7–3J-95–9U-T4-X1| 10.204.4.100|

Setting up the Pi Kernel:

Once you install the OS to the correct SD card, transfer them to the pi’s and plug in the power supply, micro HDMI, and keyboard. Give it 2 to 3 mins to load, but when you see the insert username, wait until it has more scripts run. If you were able to set a static IP address, another way you can access the Pi’s is by adding the SSH into them from your local computer.

$ ssh ubuntu@10.204.4.100

Once that is finished, you can use these credentials:

Username: ubuntu
Password: ubuntu

Once logged in, you will be prompted to change your password. Use any password of your choosing.

Once you have officially logged in to your raspberry pi, we will start running it.

$ sudo dhclient eth0

Then the next step would be to determine the IP address of the Raspberry Pi’s so you can SSH into them later.

On Ubuntu, you can run:

$ arp -na | grep -i “b8”

Note, if you don’t have arp installed, you can run:

$ sudo apt install net-tools

You can now SSH into that board from any terminal.

Open a terminal and run:

$ ssh ubuntu@<RASBERRYPI-IP-ADDRESS>

Confirm you want to connect.

Once done you officially have connected to the Pi. You can add your SSH key if you want to save time for future SSH attempts:

Now, you will need to enable cgroups limit support. You will want to add these to the /boot/firmware/cmdline.txt file

Run the following command:

$ sudo vim /boot/firmware/cmdline.txt

Then add the following to the file:

cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1
Ubuntu Screenshot

After doing so you will need to restart the kernel for the changes to take effect, so run the following:

$ sudo reboot

Make sure you follow the same steps for each board as they all need to be running an Ubuntu Server image.

Now if you’re like me and have recently gotten their CKA, you want to flex those muscles and utilize everything Kubernetes offers. With that in mind, I’ll be using Kubeadm to set up the clusters and for the second part of the tutorial, I will be creating & installing the infrastructure to host Arena Concourse, something I’ll be making a tutorial later in the year.

*In the next tutorial I will also add a factor of any new additional costs for any of the new infrastructure based on energy costs.

Before we start installing Kubernetes we will need a Docker engine to do so. I’ll catch you in part 2.

I hope you’ve found this guide to building a home server useful. Feel free to explore our website to learn about Zaloni, our Zaloni Arena data governance platform, and our many resources, like our complimentary Data Governance 101 e-learning course and Zaloni’s latest data governance research report with Dataversity. 

about the author

Matthew Caspento is a Cloud Operations Engineer at Zaloni with a passion for learning and growing within the tech space. Matthew recently earned his "Full-Stack Web Development" certificate from the University of North Carolina at Charlotte. Following his certification, he launched his career in data and now puts his skills to the test every day with Zaloni's latest engineering projects and initiatives.