Cluster Hat setup - Part 1
Cluster Hat setup - Part 2
Cluster Hat setup - Part 3 - Ansible
Cluster Hat setup - Part 4 - Docker Registry
Cluster Hat setup - Part 5 - Access Point Setup
Cluster Hat - Other Processes
Set up a new Raspberry Pi 3 to join the cluster
Step 23 - Setup access point
In summary we now have a cluster with 5 machines:
- controller
- p1
- p2
- p3
- p4
The controller has a bridge, a DHCP server and a DNS server which connects all 5 together in a network 192.168.2.*.
I have also used the an external wifi dongle to connect the Raspberry Pi 3 to the internet via my home wifi. (192.168.1.* network)
I could set up port forwarding through the external adapter to allow clients to access services running on the Pi Zero's in the cluster.
However I don't want to do this. A use case for my cluster would be to put it into a bag and bring it with my laptop to other locations and possible demo it to others. To do this I will need to connect to it somehow and setup the wifi password etc. for that location. So instead I will setup the controller raspberry Pi as a WiFi access point. This way I can always use the laptop to connect to and operate the cluster.
(I referenced https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-wi… for a lot of this step)
Only wifi adapters that support master mode can be used as wifi access points. You can check if an adapter supports master mode with the following command:
-
sudo iwconfig wlan1 mode master
-
iwconfig
To set up the access point install hostapd on the controller:
-
sudo apt-get install hostapd
The wlan0 section of the /etc/network/interfaces file I already used has the relevant entry for wlan0 access point:
-
##wlan0 is the interface for the access point
-
allow-hotplug wlan0
-
iface wlan0 inet manual
-
pre-up brctl addif br0 wlan0
Then I created a config file for hostapd:
-
sudo nano /etc/hostapd/hostapd.conf
and used:
-
interface=wlan0
-
bridge=br0
-
-
driver=nl80211
-
-
#SSID of network
-
ssid=Pi_Cluster_Admin
-
-
# Use the 2.4GHz band
-
hw_mode=g
-
-
# Use channel 6
-
channel=6
-
-
# Enable 802.11n
-
ieee80211n=1
-
-
# Enable WMM
-
wmm_enabled=1
-
-
# Enable 40MHz channels with 20ns guard interval
-
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
-
-
# Accept all MAC addresses
-
macaddr_acl=0
-
-
# Use WPA authentication
-
auth_algs=1
-
-
ignore_broadcast_ssid=0
-
-
# Use WPA2
-
wpa=2
-
-
# Use a pre-shared key
-
wpa_key_mgmt=WPA-PSK
-
-
# The network passphrase
-
wpa_passphrase=raspberry
-
-
rsn_pairwise=CCMP
(Of course I didn't use this passphrase)
I ran the command
-
sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
The access point appeared and I was able to log in with my phone!
I enabled the service permanently by editing the file sudo nano /etc/default/hostapd and setting:
-
DAEMON_CONF="/etc/hostapd/hostapd.conf"
I then entered the command
-
sudo systemctl enable hostapd
I then rebooted the cluster.
Step 24 - Final Checkpoint
You can check this setup has worked by disconnecting the laptop from the home wifi and connecting it to the Pi_Cluster_Admin. It should still be possible to access the internet through this connection.
As the laptop is on the same network as the cluster you can also load a browser and connect to http://p1/ or http://p1.metcarob-local.com/ and see the apache welcome page.
Summary
And that's the end of the tutorial. I plan to use this as a platform for future adventures learning Ansible, Docker, Microservices, and more. I have created a quick reference page for process I use maintain the cluster here - Cluster Hat - Other Processes.
If you have found any issues, improvements with this tutorial then it would be great if you share them with me so I can correct and improve my setup. I should be active in the clusterhat forum (https://groups.google.com/forum/#!forum/clusterhat)
Cameron MacFarland has created similar steps to what I have followed as an Ansible setup process which is available here: https://github.com/distantcam/ansible-rpi-playbooks
I haven't run it myself but it looks like a great one step way to achieving a similar result to this tutorial.