-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-firecracker.sh
executable file
·58 lines (47 loc) · 1.6 KB
/
setup-firecracker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# run firecracker with
# sudo firecracker --api-sock /tmp/firecracker.socket
# need to run this script as root
ROOTFS_PATH=/home/sautax/git/grobuzin-agent/image-builder/rootfs.ext4
KERNEL_PATH=/home/sautax/git/grobuzin-agent/kernel/vmlinux
curl -X PUT --unix-socket /tmp/firecracker.socket -i \
--data '{
"vcpu_count": 2,
"mem_size_mib": 1024
}' "http://localhost/machine-config"
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT "http://localhost/drives/rootfs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"drive_id": "rootfs",
"path_on_host": "'$ROOTFS_PATH'",
"is_root_device": true,
"is_read_only": false
}'
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT "http://localhost/boot-source" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"kernel_image_path": "'$KERNEL_PATH'",
"boot_args": "console=ttyS0 reboot=k panic=1 pci=off"
}'
# network
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT "http://localhost/network-interfaces/eth0" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"iface_id": "eth0",
"guest_mac": "AA:FC:00:00:00:01",
"host_dev_name": "tap0"
}'
# start the microVM
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT "http://localhost/actions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"action_type": "InstanceStart"
}'