πŸš€ Step-by-Step Guide: Setting Up a Kubernetes Cluster on Raspberry Pi 5 with K3s

🧭 Table of Contents

  1. πŸ” Why K3s?
  2. πŸ› οΈ Requirements
  3. πŸ–₯️ Preparing the Raspberry Pi Nodes
  4. πŸ—οΈ Step-by-Step Guide to Using Raspberry Pi Imager
  5. πŸ”— Connecting to Raspberry Pi 5 Boards
  6. 🐳 Installing Kubernetes on Raspberry Pi 5
  7. 🏁 Conclusion

🧐 Why K3s?

If you’re looking to dive into Kubernetes with minimal hassle, K3s is the way to go! 🌟 K3s is a lightweight Kubernetes distribution, perfect for environments with limited resources like Raspberry Pi. It’s designed for IoT and edge computing, making it an ideal fit for ARM-based devices like the Raspberry Pi. πŸ₯³

Why K3s?

  • πŸ’‘ Optimized for ARM: Perfect for Raspberry Pi.
  • πŸ› οΈ Easy Installation: No need to wrestle with complex setups.
  • πŸ”‹ Lightweight: Uses fewer resources, leaving more room for your apps!

While K3s is fantastic, alternatives like Kubeadm are also available. However, they may not be as efficient on resource-constrained devices like the Raspberry Pi.


πŸ”§ Requirements

Hardware:

  • πŸ“ Two or more Raspberry Pi 5 boards (older versions work too!)
  • πŸ”Œ Stable power supply for each board
  • πŸ’Ύ High-quality microSD cards (16GB+ recommended)
  • 🌐 Network to connect Raspberry Pi nodes

Software:

  • 🐧 Raspberry Pi OS
  • πŸ’» Raspberry Pi Imager (or Etcher, Rufus)
  • πŸ” SSH client for remote access

πŸ–₯️ Preparing the Raspberry Pi Nodes

First things firstβ€”prepare your Raspberry Pi nodes. To make your life easier, consider a headless setup. This means you don’t need to connect a monitor, keyboard, or mouse. Everything can be done remotely! πŸ–§

Pro Tip: Use the Raspberry Pi Imager to simplify the setup process by enabling SSH and connecting to Wi-Fi during installation. This will save you tons of time later! ⏱️


πŸ—οΈ Step-by-Step Guide to Using Raspberry Pi Imager

Here’s how to quickly set up your Raspberry Pi OS using Raspberry Pi Imager:

  1. 🌐 Download the Raspberry Pi Imager from the official website.
  2. πŸ› οΈ Install the Imager on your computer.
  3. πŸ” Select your Raspberry Pi model in the Imager to ensure you download the correct OS.
  4. πŸ’Ύ Insert your microSD card and choose it in the Imager.
  5. πŸ–₯️ Customize your OS settings, such as Hostname and SSH, for a headless setup.
  6. ⏳ Write the OS to the microSD card and safely eject it.
  7. πŸ”Œ Power up your Raspberry Pi with the flashed microSD card.

πŸ”‘ Important: Ensure all your Raspberry Pi boards are connected to the same network, either via Ethernet or Wi-Fi.


πŸ”— Connecting to Raspberry Pi 5 Boards

Once your Raspberry Pi is up and running, it’s time to connect! πŸŽ‰

  1. πŸ” Find the IP Address of your Raspberry Pi using a network scanner or your router’s interface.
  2. πŸ’» SSH into your Raspberry Pi using its IP address:
    sudo ssh pi@<your_raspberry_pi_ip>
  3. πŸ”’ Assign Static IPs to your Raspberry Pi boards to prevent IP changes. You can either set this up via your router or by editing the interfaces file directly on the Pi.
    Example for Wi-Fi (wlan0):
    auto wlan0 iface wlan0 inet static address 192.168.1.101 netmask 255.255.255.0 gateway 192.168.1.254

🐳 Installing Kubernetes on Raspberry Pi 5

Now, let’s get Kubernetes up and running! πŸƒβ€β™‚οΈ

  1. Enable cgroups by adding this to /boot/firmware/cmdline.txt:
    cgroup_memory=1 cgroup_enable=memory
  2. Install K3s on the master node:
    sudo curl -sfL https://get.k3s.io | sh -
  3. Check K3s Status:
    sudo systemctl status k3s
  4. Access kubectl (the Kubernetes command-line tool):
    sudo kubectl get nodes

πŸ“ˆ Adding Worker Nodes

Scale your cluster by adding worker nodes! 🀝

  1. Connect the worker node to the same network as the master node.
  2. Run the installation script on the worker node, specifying the master node’s IP and token:
    sudo curl -sfL https://get.k3s.io | K3S_URL=https://<master_node_ip>:6443 K3S_TOKEN=<your_token> sh -
  3. Verify the worker node is added:
    sudo kubectl get nodes

🏁 Conclusion

Congratulations! πŸŽ‰ You’ve successfully set up a Kubernetes cluster on Raspberry Pi 5 using K3s. From prepping the hardware to configuring the cluster, you’ve done it all. This setup is perfect for deploying and managing containerized applications on a Raspberry Pi, giving you a compact yet powerful development environment.

πŸ”— Want to learn more? Check out our resources on Kubernetes and Raspberry Pi for more advanced tips and tricks! πŸš€

Tags:

We will be happy to hear your thoughts

Leave a reply

Experience the Power of Preinstalled OS Drives and Booting Guides
Logo
Compare items
  • Total (0)
Compare
0
Ninja Silhouette 9 hours ago

Joe Doe in London, England purchased a

Joe Doe in London?

Joe Doe in London, England purchased a

Joe Doe in London?

Joe Doe in London, England purchased a

Joe Doe in London?

Joe Doe in London, England purchased a

Shopping cart