Demonstrating core cloud concepts, starting with CaaS. Not for production use.
1# Worker plane
2
3## Worker manager
4
5TODO
6
7## Manual fc vm installation
8
9Add the firecracker binary to your system.
10
11Download 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:
12
13```
14ARCH="$(uname -m)"
15release_url="https://github.com/firecracker-microvm/firecracker/releases"
16latest_version=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
17CI_VERSION=${latest_version%.*}
18latest_kernel_key=$(curl "http://spec.ccfc.min.s3.amazonaws.com/?prefix=firecracker-ci/$CI_VERSION/$ARCH/vmlinux-&list-type=2" \
19 | grep -oP "(?<=<Key>)(firecracker-ci/$CI_VERSION/$ARCH/vmlinux-[0-9]+\.[0-9]+\.[0-9]{1,3})(?=</Key>)" \
20 | sort -V | tail -1)
21
22# Download a linux kernel binary
23wget "https://s3.amazonaws.com/spec.ccfc.min/${latest_kernel_key}"
24```
25
26Add the following network rules to your system (not necessary at this stage of the project but good to have)
27
28```
29TAP_DEV="tap0"
30TAP_IP="172.16.0.1"
31MASK_SHORT="/30"
32HOST_IFACE=$(ip -j route list default | jq -r '.[0].dev')
33
34# Setup network interface on the host
35sudo ip link del "$TAP_DEV" 2> /dev/null || true
36sudo ip tuntap add dev "$TAP_DEV" mode tap
37sudo ip addr add "${TAP_IP}${MASK_SHORT}" dev "$TAP_DEV"
38sudo ip link set dev "$TAP_DEV" up
39
40# Enable IP forwarding and masquerading
41sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
42sudo iptables -P FORWARD ACCEPT
43sudo iptables -t nat -A POSTROUTING -o "$HOST_IFACE" -j MASQUERADE
44```
45
46Allow execution (chmod +x) on the create_alpine_rootfs.sh, then run it.
47
48Download the firecracker binary
49
50```
51ARCH="$(uname -m)"
52release_url="https://github.com/firecracker-microvm/firecracker/releases"
53latest=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
54curl -L ${release_url}/download/${latest}/firecracker-${latest}-${ARCH}.tgz \
55| tar -xz
56
57mv release-${latest}-$(uname -m)/firecracker-${latest}-${ARCH} firecracker
58```
59
60or compile it from source.
61
62`touch firecracker.log`
63
64Finally, to run the image:
65
66`sudo rm -f /tmp/firecracker.socket && sudo ./firecracker --api-sock /tmp/firecracker.socket --config-file firecracker-config.json`
67
68The username and password is root and root. Change that in the create_alpine_rootfs.sh file if you want.
69
70To exit the tty you'll have to `shutdown` or `reboot`.
71
72If you want to wire up the networking, complete the guest side of the host networking that we added on the host earlier:
73
74```
75ip addr add 172.16.0.2/30 dev eth0
76ip link set eth0 up
77ip route add default via 172.16.0.1 dev eth0
78echo "nameserver 8.8.8.8" > /etc/resolv.conf
79```
80### TODO: prod machines that dynamically assign internal IPs on rootfs creation time
81
82Add to /etc/network/interfaces
83
84```
85auto lo
86iface lo inet loopback
87
88auto eth0
89iface eth0 inet static
90 address 172.16.0.2
91 netmask 255.255.255.252
92 gateway 172.16.0.1
93```
94
95and at startup
96
97```
98rc-update add networking boot
99rc-service networking start
100```
101
102Hmm.. also should do something for ipv6 too.