Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Last active October 13, 2017 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81 to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81 to your computer and use it in GitHub Desktop.
OpenFAAS Wireless Setup Raspbian Stretch
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
# set the access point password
PWD=e2c5Fg_X0o!xne33
if [ $# -gt 1 ]; then
PWD=$2
fi
# setup access point and fix strech raspbian networking
if [ $# -gt 0 ]; then
curl -sSL https://gist.githubusercontent.com/Lewiscowles1986/fecd4de0b45b2029c390/raw/0c8b3af3530a35db9ab958defe9629cb5ea99972/rPi3-ap-setup.sh | bash -s -- $PWD
wget -qO /usr/lib/dhcpcd5/dhcpcd https://gist.githubusercontent.com/Lewiscowles1986/390d4d423a08c4663c0ada0adfe04cdb/raw/5b41bc95d1d483b48e119db64e0603eefaec57ff/dhcpcd.sh
fi
curl -sSL get.docker.com | sh
usermod pi -aG docker
CMDLINE=$(awk '$0=$0" cgroup_enable=cpuset cgroup_enable=memory"' /boot/cmdline.txt)
echo $CMDLINE > /boot/cmdline.txt
echo $CMDLINE > /etc/boot-cmdline.bak
echo $PWD > /etc/appass
echo "Reboot the pi before running stage2.sh"
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt-get update -qqy && apt-get install -qqy kubeadm
swapoff -a
iptables -F
if [ $# -gt 0 ]; then
iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE && iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT && iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
kubeadm reset
KUBEADM_JOIN=$(kubeadm init --apiserver-advertise-address=10.0.0.1 --token-ttl 0 | grep "kubeadm join --token ")
echo $KUBEADM_JOIN > /etc/kubernetes-join
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
fi
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
# get dashboard
curl -sSL https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard-arm.yaml | kubectl create -f-
# FaaS-netes
git clone https://github.com/weikinhuang/faas-netes
cd faas-netes
git checkout 6ef67c408915dd28adfe789eb8ab8e89bb9d3cd2
kubectl apply -f ./faas.armhf.yml,monitoring-config.yml,monitoring.armhf.yml
# get the rest of the serverless functions you like... Have fun
@Lewiscowles1986
Copy link
Author

😆 note to self... resize fs. @ 2GB root the damn thing fills up the device

@Lewiscowles1986
Copy link
Author

Pre-requisites

  • Password (to share in wpa-supplicant.conf for nodes)
  • wpa-supplicant.conf for master node
  • spare usb-wireless (or ethernet, but you'll need to modify the adapter in stage2 to use ethernet)

Master

curl -sSL https://gist.github.com/Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81/raw/311ebcb03334532aca0b90245091a693d94e48a9/stage1.sh | sudo bash -s -- admin YourSecretPassword
sudo reboot
curl -sSL https://gist.github.com/Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81/raw/311ebcb03334532aca0b90245091a693d94e48a9/stage2.sh | sudo bash -s -- admin
cat /etc/kubernetes-join

Repeat for nodes

curl -sSL https://gist.github.com/Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81/raw/311ebcb03334532aca0b90245091a693d94e48a9/stage1.sh | sudo bash -s --
sudo reboot
curl -sSL https://gist.github.com/Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81/raw/311ebcb03334532aca0b90245091a693d94e48a9/stage2.sh | sudo bash -s --
#Change Hostname (don't know why, but it seems to matter)
#Output from /cat/kubernetes-join

Back to master

sudo kubectl apply -f https://git.io/weave-kube-1.6
curl -sSL https://gist.github.com/Lewiscowles1986/4f451bfaabb238dc6a3147194a759e81/raw/311ebcb03334532aca0b90245091a693d94e48a9/stage3.sh | sudo bash -s --

Should be done. Don't reboot 😸

@Lewiscowles1986
Copy link
Author

Lewiscowles1986 commented Oct 13, 2017

Oh I'm using ssh pi@raspberrypi.local -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no to connect to the main Pi.
ssh pi@10.0.0.{x} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no (from main/master Pi) to connect to the nodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment