Create an Kubernetes cluster with Raspberry Pi 3 (Also work with 1/2) and set it up in 20 minutes using Ansible and kubeadm.
Based on Roland Huß's job and originally inspired by the post Creating a Raspberry Pi cluster running Kubernetes by Arjen Wassink and Ray Tsang.
This project automates all the configuration steps described in the Kubernetes documentation + some basic setup for all nodes.
Here is the hardware you will need to complete the project:
|5||Raspberry Pi 3||5 * 39 EUR|
|5||Micro SD Card 32 GB||5 * 11 EUR|
|1||WLAN Router||24 EUR|
|1||100 MB Switch||12 EUR|
|5||Micro-USB wires||5 * 1 EUR|
|1||Power Supply||43 EUR|
|3||Multi stackable case||3 * 16 EUR|
|1||Bolt pack||6 EUR|
Here is the software you will need to complete the project:
|Ansible||Website||Ansible installation guide|
Download the latest HypriotOS image from the hypriot/rpi-image-builder release page
For each SD card, flash the image (v.1.1.3 in this case).:
$ flash hypriotos-rpi-v1.1.3.img
Put the SD card in all the Pis.
RECOMMENDED: For each Pi, turn it on, find out its MAC address (e.g. using your router), set a static IP from them and reboot them to get the new IP.
Copy "hosts.example" to "hosts" and edit the file.
Apply the base configuration for all Pi:
$ ansible-playbook -k -i hosts setup.yml
IMPORTANT: Amongs others, the setup copies your public SSH key to all Pis and associates it to the user "Pi". Is important to check that the key exists at "~/.ssh/id_rsa.pub".
You can create a new key using the command:
ssh-keygen -t rsa -b 4096
You can set another path in /roles/base/defaults/main.yml.
Copy config.example.yml to config.yml
Create the Kubernetes cluster:
$ ansible-playbook -i hosts master.yml
Join the nodes to the cluster:
$ ansible-playbook -i hosts nodes.yml
OPTIONAL: The "master.yml" file has copied for you the admin.config file from the master. This file is required to use kubectl from your computer.