Giter Site home page Giter Site logo

schachte / firecracker-vm-wizard Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 0.0 27 KB

๐Ÿ”ฅ Helper program for setting up a Firecracker microVM on a fresh metal

Home Page: https://ryan-schachte.com

Shell 91.76% Dockerfile 8.24%
firecracker lamda microvm mvm virtual-machine

firecracker-vm-wizard's Introduction

๐Ÿ”ฅ๐Ÿง™ Firecracker MicroVM Wizard

Simplifying the Firecracker VM setup process. Inspired by gruchalski.


DigitalOcean Referral Badge

If my work is helpful to you, please consider using my Digital Ocean referral code above for DO credit

Table of contents

Usage

git clone [email protected]:Schachte/Firecracker-VM-Helper.git && \
cd Firecracker-VM-Helper && \
./wizard
๐Ÿง™๐Ÿ”ฅ Firecracker Setup Wizard

1) Download Linux kernel binary
2) Install Firecracker
3) Install Docker
4) Setup Firecracker filesystem
5) Setup Firecracker config JSON
6) Run Firecracker
7) Exit
Pick a number โžก๏ธ 

Setting up Firecracker from scratch on Linux

โš ๏ธ This entire repo only runs on Linux. You can rent a VM, but it must support virtualization (ie. Google Cloud, Digital Ocean, EC2).

โ„น๏ธ You can skip this and just run all the defaults without issue. I'm just adding context below in case you want to make custom modifications.

Basic setup & pre-reqs

  1. Download the Linux kernel binary via option 1 of the wizard
  2. Install Firecracker onto the PATH view option 2 of the wizard
  3. Install Docker (if you don't already have) via option 3 of the wizard

Configuring your custom image

You're free to modify this as you please, but there is a minimal alpine image located in fs/rootfs.Dockerfile. This will auto-configure and boot sshd on init so you can SSH into the VM once it boots up. Password-based login is disabled.

You can modify the Dockerfile if needed, but to generate the image, we will leverage Docker, but extract the filesystem from it then remove the image from the local filesystem since it will no longer be needed.

  1. Configure the image for Firecracker via option 4 of the wizard

Generate the VM configuration details

There are a few ways to launch a VM, we will be launching the VM via the firecracker binary giving it a JSON path to the dynamically generated configuration. There will be several questions asked during config generation:

Enter TAP IP Address (default: 172.16.0.1/24)

Enter Firecracker IP Address (default: 172.16.0.2/24)

Enter guest MAC address (default: 02:FC:00:00:00:05)

Enter VM memory usage (default: 128 mib)

Enter TAP name (default: tap-fc-dev)

In this case, at least for testing, defaults should work for you out of the box. I'm automatically generating a TAP interface within the configuration setup. This is the network bridge used between the host and the VM to control the flow of packets in and out of the virtual machine.

  1. Generate config via option 5 of the wizard.

Run the MVM

  1. Run option 6 and the micro-VM will start and present a login.

If you'd like to just run the VM manually and in the background so you can SSH within the same terminal session, then run:

export CONFIG_LOCATION=/firecracker/configs
$ sudo firecracker --no-api --config-file $CONFIG_LOCATION/alpine-config.json 

Note: You will be presented with a login screen. This is useless based on the default config in the Dockerfile because I've disabled logging in via password. Kill the session and use SSH to access the VM.

Accessing the machine via SSH

ssh -i ~/.ssh/hacker [email protected]

You can change the details of the key name in fs/fs.sh and the user login username via the Dockerfile in fs/rootfs.Dockerfile

root@vm:~# ssh -i ~/.ssh/hacker [email protected]

The authenticity of host '172.16.0.2 (172.16.0.2)' can't be established.
ED25519 key fingerprint is SHA256:0vI9w7kxgB8hX/J3N5jRWXo5CNxlmryoGYTQEpGpOoI.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added '172.16.0.2' (ED25519) to the list of known hosts.
Welcome to Alpine!

The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org/>.

You can setup the system with the command: setup-alpine

You may change this message by editing /etc/motd.

172:~$

firecracker-vm-wizard's People

Contributors

schachte avatar

Stargazers

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

Watchers

 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.