Scripts to assist with the creation of a raspberry pi kubernetes cluster.
This repository will help and guide you on setting up a cluster with multiple raspberries pi.
Currently it can generate a master
and N
-workers
where N
is the number of
nodes chosen in the conf.json
.
It configures a DHCP server making the master
node start assigning IPs to the worker nodes.
It is expected for the raspberries to be connected to the same switch.
The eth0
interface should be reserved for the cluster.
The objective of this project is to make it easy to configure a cluster in order to start playing with Kubernetes.
git clone https://github.com/Woile/rpi-cluster-assistant.git
cd rpi-cluster-assistant/
./scripts/init
./scripts/flash-cluster
Once the SD cards have been flashed, plug them in the raspberries. I'd recommend starting with the SD containing the master node.
- Access using
SSH
to the nodes. - DHCP Server and
master
node with static IP10.0.0.1
- Range of IPs assigned to nodes goes from
10.0.0.2
to10.0.0.50
- All the nodes have access to wifi. This might be useful later to play with multi-master nodes.
- Provision a
kubernetes
cluster - Support for multiple pod networks:
flannel
,weavenet
- Include kubernetes addons, currently only dashboard.
- Prompt asking for the configuration of the cluster.
- Linux Debian based OS.
- Python 3.x
Execute:
./scripts/init
Explanation:
- Installs OS dependencies (debian) in your machine (the host).
- Downloads
Hypriot OS
andflash
. - Create 'conf.json' using the assistant if file is not present.
Before:
- Update
config.json
values.
Execute:
./scripts/flash-cluster
Explanation:
- Show information of what is going to happen and ask for confirmation.
- Render cluster files.
- If master node is true, it will be the first to be flashed.
- The worker nodes will be flashed.
Execute:
./scripts/assistant.py
Explanation:
- Questions about the cluster are prompted.
- A
conf.json
file is generated.
Before:
- Update
config.json
values.
Execute:
./scripts/flash-one
Explanation:
- Prompt the user for some information.
- Render cluster files.
- Flash one SD card based on the node type (
master
orworker
) chosen.
Before:
- Update the values in
conf.json
. - Use the raw wifi password because it will be automatically converted using
wpa_passphrase
. - If you don't have a ssh key, create one using this tutorial.
Execute:
./scripts/render.py
Explanation:
- Reads information from
conf.json
. - Creates files for Raspberry cluster inside
output
folder.
The configuration file can be created based on the conf.example.json
cp conf.example.json conf.json
All the values are required, if you don't know what to put, leave the default.
Variable | Description | Default |
---|---|---|
username |
The username used to log in to the node | hypriot |
wifi_ssid_name |
The name of your wifi | - |
wifi_password |
Raw password of your wifi | - |
wifi_country |
Country where you are, check the codes | NL |
ssh_public_key |
Public SSH Key to access from outside the nodes | ~/.ssh/id_rsa.pub |
hostname_prefix |
Name of the machine. It will look like: node-1 |
node |
number_of_nodes |
Number of raspberries to be flashed | 4 |
node_range_start |
Offset to the number of nodes. Example range: [5..8] with range start: 5 |
1 |
include_master |
Decide whether to flash a master node or only workers. |
true |
pod_network |
Pod Network. Options: weavenet , flannel |
flannel |
- As root follow the steps located in
/root/k8s-cluster
. - As normal user follow the steps located in
/home/<user>/k8s-config
Notes:
- Observe the output located in
/root/k8s-cluster/kubeadm-init.out
because you will - have to run the
kubeadm join ...
after provisioning the worker nodes.
Remember that this must be executed after running all the scripts above
- As root follow the steps located in
/root/k8s-cluster
. - Run
kubeadm join ...
command which appears in the master node.
You can run the addons included in /home/<user>/k8s-addons
.