Skip to content

Commit

Permalink
Setup scripting for Vagrant
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Neyer committed Feb 7, 2021
1 parent f9016d8 commit 96bbc95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Vagrant.configure("2") do |config|

config.vm.provision "shell", path: "scripts/install.sh"
config.vm.provision "shell" do |s|
s.path = "scripts/install.sh"
s.args = "enp0s8"
end

config.vm.synced_folder ".", "/opt/stampede"

Expand Down
2 changes: 1 addition & 1 deletion pkg/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
voteCount = 10
stateFile = "/opt/stampede/is-joined"
stateFile = "/opt/stampede-is-joined"
)

var (
Expand Down
23 changes: 19 additions & 4 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#/bin/env bash
set -ex


if [ $# -eq 1 ]
then
INTERFACE_OVERRIDE=$1
fi

mkdir -p /opt/stampede

#Install Go
Expand All @@ -12,20 +18,29 @@ cd /opt/stampede && go build -o /usr/local/bin/stampede .
#Install microk8s
snap install microk8s --classic --channel=1.18/stable

#Send multicast traffic through default interface
ip route add 224.0.0.0/4 dev $(route | grep '^default' | grep -o '[^ ]*$')
#Send multicast traffic through default interface, or specified override
if [ -z "${INTERFACE_OVERRIDE}" ]
then
ip route add 224.0.0.0/4 dev $(route | grep '^default' | grep -o '[^ ]*$')
else
ip route add 224.0.0.0/4 dev "${INTERFACE_OVERRIDE}"
fi

#Setup stampede systemd service
cat << EOF > /lib/systemd/system/stampede.service
[Unit]
Description=stampede is a microk8s bootstrapping utility to elect a leader and add nodes
Description=stampede
[Service]
Type=simple
Restart=always
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/stampede
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable stampede
systemctl start stampede

0 comments on commit 96bbc95

Please sign in to comment.