Skip to content

arun-gupta/firecracker-firstlook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

First Look at Firecracker

Video 1: What is Firecracker

Slides

  1. What is Firecracker?

  2. Benefits of Firecracker

  3. Firecracker Design Principles

Video 2: Firecracker Design

Slides

  1. Firecracker Design

  2. REST API

Video 3: Firecracker and Lambda

Slides

Video 4: Firecracker and Fargate

Slides

Video 5: Getting Started with Firecracker

Prep Work

  1. Create an m5.metal instance using Amazon Linux 2 on EC2 and login:

    ssh -i ~/.ssh/arun-us-east1.pem ec2-user@<ip-address>

Code

  1. Clone and build firectl:

    sudo yum install -y git
    git clone https://github.com/firecracker-microvm/firectl
    sudo amazon-linux-extras install -y golang1.11
    cd firectl
    make
  2. Firecracker uses KVM and needs read/write access that can be granted as shown below:

    sudo setfacl -m u:${USER}:rw /dev/kvm
  3. Download the Firecracker binary:

    curl -LOJ https://github.com/firecracker-microvm/firecracker/releases/download/v0.15.2/firecracker-v0.15.2
    chmod +x firecracker-v0.15.2
    sudo mv firecracker-v0.15.2 /usr/local/bin/firecracker
  4. Download an Alpine Linux-based test kernel and a root filesystem:

    curl -fsSL -o hello-vmlinux.bin https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin
    curl -fsSL -o hello-rootfs.ext4 https://s3.amazonaws.com/spec.ccfc.min/img/hello/fsfiles/hello-rootfs.ext4
  5. Create microVM:

    ./firectl \
      --kernel=hello-vmlinux.bin \
      --root-drive=hello-rootfs.ext4
  6. Terminal 1 shows a login prompt:

    Welcome to Alpine Linux 3.8
    Kernel 4.14.55-84.37.amzn2.x86_64 on an x86_64 (ttyS0)
    localhost login:
  7. Log in as root with password root

  8. Show the filesystem:

    ls /
  9. Shutdown the machine:

    reboot

Video 6: Access the microVM using REST API

  1. Start the machine again:

    sudo setfacl -m u:${USER}:rw /dev/kvm
    ./firectl \
      --kernel=hello-vmlinux.bin \
      --root-drive=hello-rootfs.ext4
  2. In another terminal, login to the same EC2 instance:

    ssh -i ~/.ssh/arun-us-east1.pem ec2-user@<ip-address>
  3. Query the microVM:

    $ curl --unix-socket ~/.firecracker.sock-* http://localhost/
    {"id":"anonymous-instance","state":"Running","vmm_version":"0.15.2"}
  4. Get more details about the microVM:

    $ curl --unix-socket ~/.firecracker.sock-* http://localhost/machine-config
    { "vcpu_count": 1, "mem_size_mib": 512,  "ht_enabled": true,  "cpu_template": "Uninitialized" }

    Show the vCPU and memory size.

  5. Try to update the vCPU:

    $ curl --unix-socket ~/.firecracker.sock-* -X PUT http://localhost/machine-config -d '{ "vcpu_count": 2}'
    {
    "fault_message": "The update operation is not allowed after boot."
    }
  6. Try to shutdown the VM using by sending SendCtrlAltDel action:

    curl --unix-socket ~/.firecracker.sock-* -X PUT http://localhost/actions -d '{ "action_type": "SendCtrlAltDel" }'

    Explain that this will not work. Firecracker emulates a standard AT keyboard, connected via an i8042 controller. The required device drivers are not enabled in this kernel.

  7. Download a Ubuntu-based test kernel and Xenial root filesystem, that has the device drivers enabled:

    curl -fsSL -o vmlinux.bin https://s3.amazonaws.com/spec.ccfc.min/img/ubuntu_with_ssh/kernel/vmlinux.bin
    curl -fsSL -o xenial.rootfs.ext4 https://s3.amazonaws.com/spec.ccfc.min/img/ubuntu_with_ssh/fsfiles/xenial.rootfs.ext4
  8. Start a new microVM using new kernel and filesystem:

    sudo setfacl -m u:${USER}:rw /dev/kvm
    ./firectl \
      --kernel=vmlinux.bin \
      --root-drive=xenial.rootfs.ext4
  9. Query the microVM again:

    curl --unix-socket ~/.firecracker.sock-* http://localhost/machine-config
  10. Shutdown the microVM using an action:

    curl --unix-socket ~/.firecracker.sock-* -X PUT http://localhost/actions -d '{ "action_type": "SendCtrlAltDel" }'

Video 7: Firecracker and Container Integration

Slides

  1. Firecracker and Containerd

  2. Firecracker and Kata Containers

Code

  1. Install eksctl CLI:

    brew tap weaveworks/tap
    brew install weaveworks/tap/eksctl
  2. Create EKS cluster:

    eksctl create cluster --name kata --nodes 4
  3. Install Kata:

    kubectl apply -f https://raw.githubusercontent.com/kata-containers/packaging/master/kata-deploy/kata-rbac.yaml
    kubectl apply -f https://raw.githubusercontent.com/kata-containers/packaging/master/kata-deploy/kata-deploy.yaml
  4. Deploy a pod using kata-fc runtime:

    kubectl apply -f https://raw.githubusercontent.com/kata-containers/packaging/master/kata-deploy/examples/test-deploy-kata-fc.yaml
  5. Get pod details:

    kubectl describe pod <>

Video 8: Next Steps with Firecracker