Skip to content

Instantly share code, notes, and snippets.

@XavM
Last active December 31, 2022 15:17
Show Gist options
  • Save XavM/b15141fe6088066345c6e59ede20416a to your computer and use it in GitHub Desktop.
Save XavM/b15141fe6088066345c6e59ede20416a to your computer and use it in GitHub Desktop.
clusterhat/docker swarm

ClusterHat

Docs

Misc

If USB Booting using Sabrant USB/SAS Adaptor, add the following to cmdline.txt (as a "prefix" to anything else)

usb-storage.quirks=152d:1561:u 

Get USB Boot Image and deploy it on controller

Uncomment the appropriate USB Port then init clusterhat

sudo vi /etc/default/clusterctrl
sudo clusterctrl init
wget https://dist1.8086.net/clusterctrl/usbboot/bullseye/2022-04-04/2022-04-04-3-bullseye-ClusterCTRL-armhf-lite-usbboot.tar.xz
sudo su
tar -axf ./2022-04-04-3-bullseye-ClusterCTRL-armhf-lite-usbboot.tar.xz -C /var/lib/clusterctrl/nfs/p1/
usbboot-init 1
touch /var/lib/clusterctrl/nfs/p1/boot/ssh
cd /var/lib/clusterctrl/nfs/p1
set +o history
echo "$LOGIN:"$(echo '$PASSWD' | openssl passwd -6 -stdin) > boot/userconf.txt
set -o history

Start pi zero

clusterctrl status
clusterctrl on p1
tail -f /var/log/daemon.log /var/log/kern.log

Connect pi zero

ssh p1.local

or

minicom p1 # Quit minicom: Ctrl+A && Q && [ENTER]

Misc

"ip a" should show one "ethupiX" per pi zero (with X pi zero nbr from 1 to 4) "brctl show" should show each zero interface in the bridge

Docker Swarm

Install Docker and Init Swarm

sudo apt update && sudo apt install docker.io
sudo usermod -aG docker pi
docker swarm init
docker swarm join-token manager
docker swarm join-token worker

On the other managers/workers

docker swarm join --token $TOKEN 172.19.181.1:2377

Install HTTP viz service

docker service create \
  --name=viz \
  --publish=8080:8080/tcp \
  --constraint=node.role==manager \
  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
  alexellis2/visualizer-arm:latest

Create a "simple" HTTP service and scale it

docker service create \
  --name http \
  -p 80:80 \
  alpine:latest \
  sh -c "apk update && apk add busybox-extras && hostname > ./index.html && httpd -f"

Scale http service to 5 nodes

docker service scale http=5

Create cloudflared service

Create a "simple" HTTP service and scale it

docker service create \
  --name cloudflared \
 cloudflare/cloudflared:latest \
 tunnel --no-autoupdate run --token ${TUNNEL_TOKEN}

<- Don't work : ERR Couldn't start tunnel error="Error getting origin cert: client didn't specify origincert path"

docker run -d --restart unless-stopped  \
  cloudflare/cloudflared:latest  \
  tunnel --no-autoupdate run --token ${TUNNEL_TOKEN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment