Hackernoon logoHow To Deploy Firecracker MicroVMs using Weave FireKube by@sudip-sengupta

How To Deploy Firecracker MicroVMs using Weave FireKube

Author profile picture

@sudip-senguptaSudip Sengupta

Solution Architect | Technical Content Writer


At their 2018 annual Re:Invent conference, AWS announced an exciting new product called "Firecracker" that is quickly setting the cloud-native ecosystem on fire. Firecracker isĀ a Virtual Machine ManagerĀ (VMM) exclusively designed for running transient and short-lived processes. In other words, it is optimized for running functions and serverless workloads that require faster cold start and higher density.

Using the same technology that Amazon uses for AWS Lambda and AWS Fargate, Firecracker delivers the speed of containers with the security of VMs and has the potential to disrupt the current container and serverless technologies.

What is Weave Ignite?

While Firecracker has a ton of potential, it's still in its early stages so getting it up and running can be a bit tedious. The goal ofĀ IgniteĀ is to solve this issue by adopting its developer experience fromĀ containers.

With Ignite, you just pick a container image that you want to run as a VM and then executeĀ 

ignite run
Ā instead ofĀ 
docker run

Thereā€™s no need to use VM-specific tools to buildĀ 
, or
images, just do aĀ 
docker build
Ā from any base image you want (e.g.
Ā from Docker Hub), and add your preferred content.

You can even use Buildpacks! As seen in my other blog postĀ here. In this case, you would just follow the same steps, except you would build the image via theĀ 
Ā command.

What is Firekube?

Firekube is a new open-source Kubernetes distribution that enables the use of Weave Ignite and GitOps to enable the setup of secure VM clusters. Firekube pulls everything from Git, detects your operating system and can boot up a secure cluster of VMs from nothing in 2.5 minutes.

A Firekube cluster has the following properties:

  1. Runs Kubernetes (now K8s, possibly K3s in future)
  2. High-grade VM security via the Firecracker KVM isolation
  3. Fast start-up and tear down of VMs e.g. for functions and serverless apps
  4. Scales from zero to production - uses standard k8s plugins for networking, etc
  5. ā€œLift and shiftā€ software into VMs
  6. Run containers inside VMs or alongside VMs on the same CNI network

Creating a Firekube Cluster

Firekube is a Kubernetes cluster working on top ofĀ IgniteĀ andĀ Firecracker. Firekube clusters are operated withĀ GitOps.

IgniteĀ andĀ FirecrackerĀ only works on Linux as they needĀ KVM. However, it will also work on macOS usingĀ footloose: the Kubernetes nodes are then running inside containers.

Prerequisites: Docker, Git,Ā kubectl 1.14+.

1. Fork this repository.

2. Clone your fork andĀ 

Ā into it. Use theĀ 
Ā git URL as the script will push an initial commit to your fork:

export user="" # Your GitHub handle or org

git clone git@github.com:$user/wks-quickstart-firekube.git
cd wks-quickstart-firekube

3. Start the cluster:


This step will take several minutes.

Export theĀ KUBECONFIGĀ environment variable as indicated at the end of the installation:

export KUBECONFIG=/home/damien/.wks/weavek8sops/example/kubeconfig

Enjoy your Kubernetes cluster!

$ kubectl get nodes
NAME               STATUS   ROLES    AGE     VERSION
67bb6c4812b19ce4   Ready    master   3m42s   v1.14.1
a5cf619fa058882d   Ready    <none>   75s     v1.14.1

Watch GitOps in action

Now that we have a cluster installed, we can commit Kubernetes objects to the git repository and have them appear in the cluster. Let's addĀ podinfo, an example Go microservice, to the cluster.

kubectl apply --dry-run -k github.com/stefanprodan/podinfo//kustomize -o yaml > podinfo.yaml
git add podinfo.yaml
git commit -a -m 'Add podinfo Deployment'
git push

A few seconds later, you should witness the apparition of a podinfo pod in the cluster:

$ kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
podinfo-677768c755-z76xk   1/1     Running   0          30s

To viewĀ podinfoĀ web UI:

1. ExposeĀ 

Ā locally:

kubectl port-forward deploy/podinfo 9898:9898

2. Point your browser toĀ

Deleting a Firekube cluster



Using a private git repository with firekube

To use a private git repository instead of a fork ofĀ 


1. Create a private repository and push theĀ 

Ā branch there. Use the SSH git URL when cloning the private repository:

git clone git@github.com:$user/$repository.git
cd $repository
git remote add quickstart git@github.com:weaveworks/wks-quickstart-firekube.git
git fetch quickstart
git merge quickstart/master
git push

2. Create an SSH key pair:

ssh-keygen -t rsa -b 4096 -C "damien+firekube@weave.works" -f deploy-firekube  -N ""

3. Upload the deploy key to your private repository (with read/write access):

4. Start the cluster:

./setup.sh --git-deploy-key  ./deploy-firekube

Final thoughts

You've now learned the basic steps it requires to provision a Kubernetes cluster based on Firecracker VM's with Firekube. You should explore a bit of the different options the platform provides such as using Ignite to spin up MicroVM's with Buildpack instead of Docker. I hope you liked this post, and I plan to dive into this a bit more in the future. Thanks for reading!

About the author - Sudip is a Solution Architect with more than 15 years of working experience, and is the founder ofĀ Javelynn. He likes sharing his knowledge by regularly writing forĀ Hackernoon,Ā DZone,Ā AppfleetĀ and many more. And while he is not doing that, he must be fishing or playing chess.

Previously posted atĀ https://appfleet.com/.


Join Hacker Noon

Create your free account to unlock your custom reading experience.