Please see original article here.
An autoconfiguring stack to build simple, scalable, and fully binary ARM compatible Raspberry Pi clusters on Intel or AMD architecture.
- Linux (host OS)
- Docker
- QEMU (containerized inside Docker)
- Raspbian (containerized inside QEMU)
- Docker Compose
- Ansible (on host)
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt -y install docker-ce
sudo usermod -aG docker ${USER}
exec ${SHELL}
git clone https://github.com/mrhavens/pidoc.git
cd pidoc
The Dockerfile
is used to build two containers. The first container is the build container that includes all the dependencies for compiling QEMU, and the other is the app container for running QEMU.
docker build -t pidoc .
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Docker Compose is used for cluster creation. ssh
is redirected from port 2222
inside the container to random ports within the specified range, as below.
# docker-compose.yml
#
version: '3'
services:
node:
image: pidoc
ports:
- "2201-2203:2222"
To bring up three nodes as configured above with docker-compose
, use the --scale
option.
docker-compose up --scale node=3
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible -y
To manage the cluster, once the containers start and Raspbian boots, ssh will be enabled and become available to Ansible. A few basic operations are provided here: update
, upgrade
, reboot
, and shutdown
. These can be expanded as needed to develop a more robust system.
Please note of the ports we specified in the docker-compose.yml
file earlier, and edit your hosts
inventory accordingly.
# hosts inventory
#
[all:vars]
ansible_user=pi
ansible_ssh_pass=raspberry
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
[pidoc-cluster]
node_1.localhost:2201
node_2.localhost:2202
node_3.localhost:2203
Thanks goes to: