thi-startup / spitfire

cli tool for creating, running, tampering with firecracker microvms
MIT License
4 stars 1 forks source link

clean the code #8

Closed Joe-Degs closed 1 year ago

Joe-Degs commented 1 year ago

started out cleaning the code then ended up pulling some things out and adding a utility package. then a way to create a loop drive from an image.

Joe-Degs commented 1 year ago

Ohh and i've already merge your branch feat/add-rootfs-build into main (and this branch) accidentally so if you want to do any other work on that front, you will have to go through here or something. Sorry!

bxffour commented 1 year ago

lgtm

bxffour commented 1 year ago

This is a makefile that displays the new workflow. So basically we're building a rootfs drive from a docker image and running it on firecracker. This showcases our init and spitfire working together to launch images. We should be looking to moving from firectl to an integrated solution in future updates

KERNEL_OPTS = 'ro console=ttyS0,115200n8 noapic reboot=k panicOD=1  pci=off nomodules init=/thi/init'

build/init:
    @echo "building init drive"
    sudo spitfire mkroot --name tmpinit --fs ext2 --size 100M --init --build-from .
    cp tmpinit scratch/tmpinit

run/rootfs: build/init
    @echo "building rootfs from image"
    sudo spitfire mkroot --fs ext4 --image 'alpine:latest' --size 100M --name alpine.ext4
    cp alpine.ext4 scratch/alpine.ext4
    sudo ./scratch/firectl --cni-net fcnet --kernel ./scratch/vmlinux --root-drive ./scratch/tmpinit --add-drive ./scratch/alpine.ext4:rw --kernel-opts ${KERNEL_OPTS}