Cloud Native

Tutorial: Getting Started with Firecracker on VMware Fusion

14 Dec 2018 3:00am, by

This is the second part of the Firecracker article published last week. Having covered the basic architecture, I will walk you through the steps involved in setting up and configuring Firecracker on your local development machine.

The simplest way to explore Firecracker is to install it in an Ubuntu VM running on top of VMware Fusion. The first step is to configure VMware Fusion for Nested Virtualization.

Setting up an Ubuntu 16.04 VM with Nested Virtualization

Download and install VMware Fusion for Mac or Windows trial from VMware website. If you need a pre-configured Ubuntu 16.04 image, grab the VMDK from OSBoxes.org.

After installing Fusion, import the VMDK and create a new VM but don’t launch it yet. Access the settings to enable Intel-VTx support available under Processors and Memory configuration.

Since Firecracker needs KVM, we need to emulate hypervisor for the VM. The above configuration enables nested virtualization to run KVM on top of Fusion.

Start the Ubuntu VM and login with the username and password – osboxes andosboxes.org. Install VMware Tools, and optionally OpenSSH Server.

Install CPU Checker to ensure KVM is ready for use.


In less than 10 minutes, we have the testbed ready to experiment with Firecracker.

Note: Firecracker should work with VirtualBox and Hyper-V with the nested virtualization setting enabled. I have not tested those environments yet.

Installing and Verifying Firecracker VMM

Firecracker requires read/write access to KVM. Run the below command to enable it:

The script below will verify that the system is ready for Firecracker.


Let’s download the Firecracker binary.

Check the version of Firecracker to verify the installation.

 

Launching and Accessing Your First Firecracker VM

Open a new terminal and launch Firecracker. Before that, let’s make sure Firecracker can create its API socket.

Firecracker is now ready to serve the API.

In the second terminal, run the below commands to download the kernel and rootfs from an S3 bucket.

Start the guest kernel by passing the image and path and boot arguments

Set the guest filesystem by pointing it to the ext4 file that we downloaded.

We also need to configure the VM through the number of vCPUs and RAM.

Finally, let’s start the VM.

You should see the login prompt in the first terminal window where we started the socket. Login with user root and password root.

Congratulations! You just launched your first Firecracker VM.

Let’s play with the API to explore the machine configuration.


It’s interesting to see that the Firecracker VM is just a process with an assigned PID.

Type reboot within the Firecracker VM to halt it.
You can easily launch multiple Firecracker VMs with a simple loop.

Each VM runs in a separate process with a dedicated socket.

Next Steps

While it’s certainly fun to see Firecracker running locally, I couldn’t get past the basic steps of launching and terminating VMs. My goal is to attach a virtual NIC to a VM, and run a basic web server.

Firecracker VMs support EC2-style metadata which can be set and queried from an external API client. I am also trying to get that working.

Firecracker’s integration with containerd is in pipeline. As soon as that becomes stable, Kubernetes can control the lifecycle of Firecracker VMs. I am eagerly waiting for that to happen.

As I discover new capabilities and use cases, I will share the findings with you. Stay tuned.

VMware is a sponsor of The New Stack.

A newsletter digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.