···1+[package]
2+name = "job-board-orchestrator"
3+version = "0.1.0"
4+edition = "2024"
5+6+[dependencies]
7+# The core async runtime for Rust
8+tokio = { version = "1", features = ["full"] }
9+10+# WebSocket library that integrates with Tokio
11+tokio-tungstenite = "0.23"
12+13+# Utilities for working with async streams and sinks
14+futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
15+16+# Framework for serializing and deserializing Rust data structures
17+serde = { version = "1.0", features = ["derive"] }
18+19+# A JSON implementation for Serde
20+serde_json = "1.0"
21+22+# For generating unique identifiers for jobs
23+uuid = { version = "1.8", features = ["v4"] }
24+25+# A framework for structured, event-based logging
26+tracing = "0.1"
27+28+# A subscriber for the tracing framework that formats and outputs logs
29+tracing-subscriber = "0.3"
30+
+11
control-plane/job-board/README.md
···00000000000
···1+# Job board
2+3+This posts jobs for worker nodes to try to bid to recieve. So far in the development, the node with the most available resources wins.
4+5+More coming soon.
6+7+Here's an example response from a worker node in case you want to `wscat` to the job board to test responses:
8+9+bash```
10+{ "type": "BidResponse", "job_id": "PASTE_THE_JOB_ID_HERE", "available_cpu_cores": 999, "available_ram_mb": 99999, "available_storage_mb": 999999 }
11+```
···1+# The VM that contains a given pod
2+3+## Manual installation
4+5+Add the firecracker binary to your system.
6+7+Download a vmlinux* that has the virtio etc installed in itself and not as modules. For example, AWS seems to have one readymade, from the firecracker docs:
8+9+```
10+ARCH="$(uname -m)"
11+release_url="https://github.com/firecracker-microvm/firecracker/releases"
12+latest_version=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
13+CI_VERSION=${latest_version%.*}
14+latest_kernel_key=$(curl "http://spec.ccfc.min.s3.amazonaws.com/?prefix=firecracker-ci/$CI_VERSION/$ARCH/vmlinux-&list-type=2" \
15+ | grep -oP "(?<=<Key>)(firecracker-ci/$CI_VERSION/$ARCH/vmlinux-[0-9]+\.[0-9]+\.[0-9]{1,3})(?=</Key>)" \
16+ | sort -V | tail -1)
17+18+# Download a linux kernel binary
19+wget "https://s3.amazonaws.com/spec.ccfc.min/${latest_kernel_key}"
20+```
21+22+Add the following network rules to your system (not necessary at this stage of the project but good to have)
23+24+```
25+TAP_DEV="tap0"
26+TAP_IP="172.16.0.1"
27+MASK_SHORT="/30"
28+HOST_IFACE=$(ip -j route list default | jq -r '.[0].dev')
29+30+# Setup network interface on the host
31+sudo ip link del "$TAP_DEV" 2> /dev/null || true
32+sudo ip tuntap add dev "$TAP_DEV" mode tap
33+sudo ip addr add "${TAP_IP}${MASK_SHORT}" dev "$TAP_DEV"
34+sudo ip link set dev "$TAP_DEV" up
35+36+# Enable IP forwarding and masquerading
37+sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
38+sudo iptables -P FORWARD ACCEPT
39+sudo iptables -t nat -A POSTROUTING -o "$HOST_IFACE" -j MASQUERADE
40+```
41+42+Allow execution (chmod +x) on the create_alpine_rootfs.sh, then run it.
43+44+`touch firecracker.log`
45+46+Finally, to run the image:
47+48+`sudo rm -f /tmp/firecracker.socket && sudo ./firecracker --api-sock /tmp/firecracker.socket --config-file firecracker-config.json`
49+50+The username and password is root and root. Change that in the create_alpine_rootfs.sh file if you want.
51+52+To exit the tty you'll have to `shutdown` or `reboot`.
53+54+If you want to wire up the networking, complete the guest side of the host networking that we added on the host earlier:
55+56+```
57+ip addr add 172.16.0.2/30 dev eth0
58+ip link set eth0 up
59+ip route add default via 172.16.0.1 dev eth0
60+echo "nameserver 8.8.8.8" > /etc/resolv.conf
61+```
62+### TODO: prod machines that dynamically assign internal IPs on rootfs creation time
63+64+Add to /etc/network/interfaces
65+66+```
67+auto lo
68+iface lo inet loopback
69+70+auto eth0
71+iface eth0 inet static
72+ address 172.16.0.2
73+ netmask 255.255.255.252
74+ gateway 172.16.0.1
75+```
76+77+and at startup
78+79+```
80+rc-update add networking boot
81+rc-service networking start
82+```
83+84+Hmm.. also should do something for ipv6 too.