firecrackerode
Node.js client for Amazon's Firecracker MicroVM platform.
Installation
npm install firecrackerode
Usage
Getting started
To use firecrackerode
first you need to instantiate it:
var Firecracker = require('dockerode');
var firecracker = new Firecracker({socketPath: '/tmp/firecracker.socket'});
Creating a MicroVM
firecracker.bootSource({
'kernel_image_path': process.cwd() + '/images/hello-vmlinux.bin',
'boot_args': 'console=ttyS0 reboot=k panic=1 pci=off'
}).then(function(data) {
var drive = firecracker.drive('rootfs');
return drive.updatePreboot({
'path_on_host': process.cwd() + '/images/hello-rootfs.ext4',
'is_root_device': true,
'is_read_only': false
});
}).then(function(data) {
return firecracker.action('InstanceStart');
}).then(function(data){
console.log('MicroVM booted!');
}).catch(function(err) {
console.log(err);
});
Helper functions
firecracker.downloadImage('https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin', os.tmpdir() + '/hello-vmlinux.bin').then(function () {
console.log('Kernel image downloaded!');
}).catch(function(err) {
console.log(err);
});
firecracker.spawn().then(function () {
console.log('Firecracker spawned!');
}).catch(function(err) {
console.log(err);
});
firecracker.kill()