GithubHelp home page GithubHelp logo

jnsgruk / firecracker-ubuntu Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 0.0 1.05 MB

๐Ÿš€ Use Firecracker and helpings of bash to boot Ubuntu virtual machines very fast ๐Ÿ”ฅ

License: Apache License 2.0

Makefile 2.07% Dockerfile 1.74% Shell 88.91% Nix 7.28%
automation docker-image firecracker firecracker-microvms kernel microvm rootfs ubuntu bash cloud-images

firecracker-ubuntu's Introduction

embr

The purpose of this project was to explore running Ubuntu with Firecracker as a general purpose development machine. This is obviously not what Firecracker was developed for, but it was an opportunity to learn a little about it!

At present, embr can download and start Ubuntu cloud images using firecracker, with support for supplying a cloud-init file to customise the virtual machine. It relies upon dnsmasq to dynamically address the VM it creates.

I took a lot of influence from ubuntu-firecracker by @bkleiner, and this blog from @ahachete in the making of this project.

Using this approach, I was able to deploy the Canonical Observability Stack with Juju on MicroK8s inside a Firecracker VM:

COS Lite on MicroK8s on Firecracker

Prerequisites

Before you can use or test this project, you'll need the following installed on your machine:

Quick start

You can start the project on a clean machine with ./embr launch.

This will do the following:

  • Download and process the relevant Ubuntu cloud image (latest LTS by default)
  • Create a network bridge device
  • Start dnsmasq on that bridge
  • Create two tap network interfaces for the VM (one for the metadata service, one for normal use)
  • Create a folder structure for a VM, containing kernel, disk, initrd and a definition file
  • Start firecracker and configure the VM over it's HTTP API
  • Start the VM

With no arguments, embr will create a VM with 8 CPUs, 16GB RAM and a 20GB disk.

Once you've run ./embr launch, you'll get instructions on how to connect to your VM.

To cleanup your machine, run ./embr clean. Note that this will, kill started processes, remove any network interfaces and delete the VM.

Customising your machine

The embr launch command takes a number of arguments such that you can customise the CPUS, memory, disk and series that is used:

$ ./embr launch --help
embr is a tool for creating and launching Ubuntu virtual machines with Firecracker.

USAGE:
        embr launch [OPTIONS]

OPTIONS:
        -n, --name <name>
                Hostname of the virtual machine to create.
                Default: dev

        -c, --cpus <cpus>
                Number of virtual CPUs to assign to the VM
                Default: 8

        -m, --memory <mem>
                Amount of memory in GB to assign to the VM.
                Default: 16

        -d, --disk <disk>
                Size of disk for the VM in GB.
                Default: 20

        -f, --cloud-init <file>
                Filename of the cloud-init user data file to use for provisioning.
                Default: userdata.yaml

        -s, --series <series>
                The Ubuntu series codename to use. E.g. xenial, bionic, focal, jammy
                Default: jammy

        -h, --help
                Display this help message.

TODO

  • Resume VM and make sure existing interfaces are present
  • Multiple VM support
    • Store VMs in separate directories
    • Start / stop VMs independently
    • Status command to show running, IP, etc.
  • Stop being a maniac and write this in Go

Done

  • Better command line arg experience
  • Output an accurate message with connection instructions on boot
  • Figure out how to run DHCP on a tap interface
  • Enable the use of standard Ubuntu cloud images
  • Enable cloud-init support
  • Add support for customising kernel and rootfs build

firecracker-ubuntu's People

Contributors

jnsgruk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.