-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cloudconfig for local vm deployment
- Loading branch information
Showing
5 changed files
with
150 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#cloud-config | ||
# | ||
# References: | ||
# - Cloudinit boot stages: https://cloudinit.readthedocs.io/en/latest/explanation/boot.html | ||
# - Modules in each stage: https://stackoverflow.com/a/37190866 | ||
|
||
# ---------------------------------------- | ||
# INIT STAGE | ||
# ---------------------------------------- | ||
|
||
# Allow password-less sudo for ubuntu and add to docker group | ||
users: | ||
- name: ubuntu | ||
sudo: 'ALL=(ALL) NOPASSWD:ALL' | ||
groups: docker | ||
|
||
ssh_authorized_keys: | ||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMYaFgA+CDCewmTdEgr14RHMXKLRkbTTIOrARMkzY0vv testing | ||
|
||
# Write the scripts to build SCION and run the network, as well as the systemd unit files | ||
# that will invoke them. | ||
write_files: | ||
- path: /etc/scion-rs-integration/build_scion.sh | ||
owner: "root:root" | ||
permissions: "0755" | ||
content: | | ||
#!/bin/bash | ||
set -euo pipefail | ||
export PATH="/home/ubuntu/.local/bin/:$PATH" | ||
git clone --depth=1 https://github.com/scionproto/scion /etc/scion-rs-integration/scion | ||
cd /etc/scion-rs-integration/scion | ||
./tools/install_bazel | ||
./tools/install_deps | ||
./scion.sh bazel-remote | ||
make build | ||
- path: /etc/scion-rs-integration/run_network.sh | ||
owner: "root:root" | ||
permissions: "0755" | ||
content: | | ||
#!/bin/bash | ||
set -euo pipefail | ||
export PATH="/home/ubuntu/.local/bin/:$PATH" | ||
EXTERNAL_ADDRESS=$(ip route get 9.9.9.9 | sed "s/.*src \([^ ]*\).*/\1/;t;d") | ||
cd /etc/scion-rs-integration/scion | ||
./scion.sh topology -c topology/tiny.topo | ||
./scion.sh run | ||
DAEMON_ADDRESS_111=$(jq -r ".\"1-ff00:0:111\"" gen/sciond_addresses.json) | ||
sudo iptables -t nat -I PREROUTING \ | ||
-d $EXTERNAL_ADDRESS -p tcp --match multiport --dports 30000:32000 \ | ||
-j DNAT --to $DAEMON_ADDRESS_111 | ||
- path: /etc/systemd/system/scion-network.service | ||
content: | | ||
[Unit] | ||
Description=Runs a local SCION network | ||
After=cloud-final.service | ||
[Service] | ||
Type=oneshot | ||
WorkingDirectory=/etc/scion-rs-integration/scion/ | ||
ExecStart=/etc/scion-rs-integration/run_network.sh | ||
ExecStop=/etc/scion-rs-integration/scion/scion.sh stop | ||
RemainAfterExit=yes | ||
User=ubuntu | ||
[Install] | ||
WantedBy=cloud-init.target | ||
# ---------------------------------------- | ||
# CONFIG STAGE | ||
# ---------------------------------------- | ||
|
||
# Setup docker sources | ||
apt: | ||
sources: | ||
docker: | ||
source: deb [signed-by=$KEY_FILE] https://download.docker.com/linux/ubuntu $RELEASE stable | ||
keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 | ||
keyserver: https://download.docker.com/linux/ubuntu/gpg | ||
|
||
# ---------------------------------------- | ||
# FINAL STAGE | ||
# ---------------------------------------- | ||
|
||
# Install required packages | ||
packages: | ||
- ca-certificates | ||
- containerd.io | ||
- curl | ||
- docker-buildx-plugin | ||
- docker-ce | ||
- docker-ce-cli | ||
- docker-compose-plugin | ||
- gnupg | ||
- make | ||
- python3-pip | ||
package_upgrade: true | ||
|
||
runcmd: | ||
- echo "net.ipv4.conf.all.route_localnet = 1" >> /etc/sysctl.conf | ||
- sysctl --system | ||
- chmod "u=rwX,g=rwX,o=rwX" /etc/scion-rs-integration | ||
- su ubuntu /etc/scion-rs-integration/build_scion.sh | ||
- systemctl enable scion-network.service | ||
- systemctl start --no-block scion-network.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-----BEGIN OPENSSH PRIVATE KEY----- | ||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW | ||
QyNTUxOQAAACDGGhYAPggwnsJk3RIK9eERzFyi0ZG00yDqwETJM2NL7wAAAJDs9PkB7PT5 | ||
AQAAAAtzc2gtZWQyNTUxOQAAACDGGhYAPggwnsJk3RIK9eERzFyi0ZG00yDqwETJM2NL7w | ||
AAAEAIEezJSN3KZg2hFur/GgEjzyPmOfrIrUs5lu9lTK/BHsYaFgA+CDCewmTdEgr14RHM | ||
XKLRkbTTIOrARMkzY0vvAAAAB3Rlc3RpbmcBAgMEBQY= | ||
-----END OPENSSH PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
# This script assumes you have set up multipass as described in CONTRIBUTING.md | ||
# and the SCION VM is running. | ||
# | ||
# Usage: . ./test_setup.sh | ||
|
||
VM_ADDRESS=$(multipass info scion | awk '/IPv4/{print $2}') | ||
|
||
export SCION_DISPATCHER_PATH=/tmp/dispatcher.sock | ||
export SCION_DAEMON_ADDRESS="[$VM_ADDRESS]:30255" | ||
|
||
rm -f $SCION_DISPATCHER_PATH | ||
ssh -i multipass/test_id_ed25519 ubuntu@$VM_ADDRESS -fN -L $SCION_DISPATCHER_PATH:/run/shm/dispatcher/default.sock |
This file was deleted.
Oops, something went wrong.