Skip to content

YOU54F/krunvm

 
 

Repository files navigation

krunvm

krunvm is a CLI-based utility for creating microVMs from OCI images, using libkrun and buildah.

Features

  • Minimal footprint
  • Fast boot time
  • Zero disk image maintenance
  • Zero network configuration
  • Support for mapping host volumes into the guest
  • Support for exposing guest ports to the host

Demo

asciicast

Supported platforms

  • Linux/KVM on x86_64.
  • Linux/KVM on AArch64.
  • macOS/Hypervisor.framework on ARM64.

Installation

macOS

brew tap you54f/krun
brew install krunvm

Fedora

dnf copr enable -y slp/libkrunfw
dnf copr enable -y slp/libkrun
dnf copr enable -y slp/krunvm
dnf install -y krunvm

Usage

Create MicroVM based on Fedora:

krunvm create {{docker.io/fedora}} --cpus {{number_of_vcpus}} --mem {{memory_in_megabytes}} --name "{{name}}"

Start a specific image:

krunvm start "{{image_name}}"

By default it will drop into sh

Start a specific image with a specific shell/command:

krunvm start "{{image_name}}" /bin/bash

List images:

  • krunvm list
  • krunvm list --json # Json output
  • krunvm list --json | jq '.vmconfig_map[].name' # List names only

Info about an image:

  • krunvm list "{{image_name}}"
  • krunvm list "{{image_name}}" --json # Json output

Change a specific image:

  • krunvm changevm --cpus {{number_of_vcpus}} --mem {{memory_in_megabytes}} --name "{{new_vm_name}}" "{{current_vm_name}}"

Delete a specific image:

  • krunvm delete "{{image_name}}"

Copy environment variables from host

NB:- Experimental feature, will probably conflict with things in your guest.

krunvm start alpine \
    --copy-environment \
    --filter-environment PATH,PWD,CWD,HOME,USER,TERMCAP,HOSTNAME,SHELL,PAGER,GPG_TTY,_,LC_TERMINAL,COLORTERM,TERM_PROGRAM,TERM_SESSION_ID,SSH_AUTH_SOCK 

Building from sources

Dependencies

Building

cargo build --release

set MACOSX_DEPLOYMENT_TARGET to 11.0 if you are building on macOS, to ensure compatibility with older versions, built of later versions of macOS. 11.0 is the earliest for arm64 macs.

#### Examples in the wild

Byzanteam/jet-deployment

https://github.com/Byzanteam/jet-deployment/tree/f6762f0f956e285a1e2b504b5de51b031a1d0950/external-services

Database

# Create the db MicroVM
krunvm create -p 5432:5432 --name airbase-db postgres:13.7-alpine

# Enter the vm
krunvm start airbase-db sh

# In the vm, initialize the db
POSTGRES_PASSWORD=postgres docker-entrypoint.sh postgres

# Exit the vm, and start the vm again
krunvm start airbase-db

Minio

# Create the minio MicroVM
krunvm create -p 9000:9000 -p 9001:9001 --name airbase-minio minio/minio

# Start the vm
krunvm start airbase-minio "minio server /data --console-address \":9001\""
# Init minio

mc alias set minio http://127.0.0.1:9000 minioadmin minioadmin

mc mb minio/minio-public --ignore-existing
mc mb minio/minio-private --ignore-existing

mc policy set download minio/minio-public

About

Create microVMs from OCI images

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 98.7%
  • Makefile 1.3%