• This repository has been archived on 28/Nov/2017
  • Stars
    star
    307
  • Rank 136,109 (Top 3 %)
  • Language
    OCaml
  • License
    Other
  • Created about 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A DNS server that automatically starts unikernels on demand

Just-In-Time Summoning of Unikernels

Jitsu is experimental software. See LICENSE for conditions.

Jitsu is a forwarding DNS server that automatically boots unikernels on demand. When a DNS query is received, Jitsu first checks for a local unikernel that is mapped to the requested domain. If a unikernel is found, the unikernel is started and its IP is returned to the client. Otherwise, the request is forwarded to the next DNS server. If no DNS requests are received for the unikernel within a given timeout period it is automatically stopped.

This version of Jitsu has been tested with MirageOS and Rumprun unikernels.

Jitsu supports several backends to manage the unikernel VMs. Currently libvirt, XAPI and libxenlight are supported. Metadata and internal state is stored in Irmin and the DNS server is implemented on top of ocaml-dns.

Build Status

Further reading

Overview

Installing Jitsu

The latest release of Jitsu is available in opam. To install Jitsu, run:

$ opam install jitsu

When Jitsu is installed it will look for available backends that can be used to start unikernels (or processes). The backends currently supported are xenctrl (libxl), libvirt and xen-api-client (xapi). If a new backend is installed opam will reinstall Jitsu to add support for it.

The virtual packages jitsu-libvirt, jitsu-xapi and jitsu-libxl can be used to force Jitsu to be installed with a specific backend.

To add a backend, either use the virtual package:

$ opam install jitsu-libxl

Or install the backend directly with opam:

$ opam install jitsu
$ opam depext xenctrl    # install external dependencies, optional
$ opam install xenctrl

To install the latest development version of Jitsu, you can pin Jitsu to the current master branch on Github. This version is unstable and changes frequently.

$ opam pin add jitsu --dev
$ opam install jitsu

If the installation succeeds you should now be able to start Jitsu. If you ran into problems and are using OS X, see below for additional troubleshooting tips.

OS X troubleshooting

To install the OCaml libvirt bindings on OS X we have to set CPPFLAGS first (due to this bug). This step can be skipped on other platforms.

$ CPPFLAGS="-Wno-error=tautological-compare -Wno-error=unused-function" \
opam install libvirt

You should now be able to install Jitsu as usual.

Getting started

Jitsu is initially launched with a list of unikernels, their configurations and a set of parameters that define

  • how to connect to the virtualization backend
  • how the DNS server should be configured
  • how the unikernels should be managed

A minimal Jitsu configuration could look like this:

$ sudo ./jitsu -c xen:/// \
dns=www.openmirage.org,\
ip=192.168.0.22,\
name=mirage-www

The command above connects to a local Xen-server (from dom0) through libvirt (the default) and starts the DNS server. Requests for www.openmirage.org will be redirected to the Xen-VM called "mirage-www" with IP 192.168.0.22. If "mirage-www" is not running, Jitsu will start it automatically before responding to the DNS request.

Each unikernel is configured using a set of key/value pairs separated by commas. The parameters that are supported depends on which virtualization backend (libvirt, xapi or libxl) is used to control the unikernels. See below or run ./jitsu --help for a complete set of options.

Examples

MirageOS web server

For this example you need a working MirageOS unikernel with a static IP address and access to dom0 on a Xen server with libxl installed. You can also install Xen in Virtualbox, as described here or use one of the Mirage Vagrant VMs. An example unikernel that displays the unikernel boot time can be found here (a live version is running here). Follow the instructions in the README to configure the network settings. After building the unikernel you should have a binary file that can be booted in Xen, usually mirage-www.xen. You can also check the generated .xl file and locate the kernel= parameter to find the file.

We should now be able to start Jitsu to manage the unikernel:

$ sudo jitsu -x libxl \
dns=www.example.org,\
ip=10.0.0.1,\
kernel=mirage-www.xen,\
memory=64000,\
name=www,\
nic=br0

This command boots the unikernel when www.example.org is resolved. The IP 10.0.0.1 is returned to clients that resolve the domain and the booted unikernel is in mirage-www.xen. The VM is given 64MB of memory and access to a network bridge at br0.

If everything worked, Jitsu should now be running a DNS server on localhost. To verify that the domain is automatically started you can run host to resolve the domain:

host www.example.org 127.0.0.1
Using domain server:
Name: 127.0.0.1
Address: 127.0.0.1#53
Aliases: 

www.example.org has address 10.0.0.1

After running host you should be able to open the web page on 10.0.0.1 (or telnet to port 80) and ping the IP.

The unikernel is automatically destroyed after the DNS cache entry expires. This timeout can be set with the --ttl parameter. See jitsu --help for a full list of available parameters and options that can be passed to the libxl backend.

nginx in rumprun

Rumprun unikernels can also be managed by Jitsu, but currently only with the libxl backend. Prior to running Jitsu, the rumprun tool must be used to generate a JSON configuration file that is passed to Jitsu using the rumprun_config parameter.

A tutorial for building a unikernel that hosts a static web page in QEMU is available here. To get a Xen unikernel, follow the instructions, but run rumpbake with the xen_pv parameter instead of hw_virtio. After baking the Xen unikernel it must be started once with rumprun to obtain the configuration files. To run the Nginx unikernel from the tutorial in Xen you could (depending on your configuration) use a command similar to this:

sudo rumprun -T tmp xen -M 64 -i \
    -b images/stubetc.iso,/etc -b images/data.iso,/data \
    -I mynet,xenif,bridge=br0 -W mynet,inet,static,10.0.0.1/24,10.0.1.1 \
    -- nginx.bin -c /data/conf/nginx.conf

The command above will boot a rumprun unikernel that mounts two disks (stubetc.iso and data.iso), connect it to the network bridge br0 and give it the IP 10.0.0.1. The -T parameter saves the generated configuration files in the tmp directory. You can verify that the unikernel booted correctly by running sudo xl list. You can also attach to the console with sudo xl console [name of unikernel]. To stop the unikernel, use sudo xl destroy [name of unikernel].

If the unikernel booted correctly we should now be able to use the file tmp/json.conf to boot it with Jitsu.

jitsu -x libxl dns=www.example.org,\
memory=64000,\
ip=10.0.0.1,\
name=rumprun,\
kernel=nginx.bin,\
disk=images/stubetc.iso@xvda,\
disk=images/data.iso@xvdb,\
nic=br0,\
rumprun_config=tmp/json.cfg 

Verify that the unikernel boots in Jitsu by running host www.example.org 127.0.0.1. An nginx web server should now be running in a rumprun unikernel on IP 10.0.0.1.

Note that rumprun unikernels currently have to wait for the disk images to be configured by Xen. When the disks are mounted as ISO files (as in this example) the total boot time can be more than a second. An alternative is to use losetup to create loopback devices that map to the ISO files. The -d parameter can also be used to delay the DNS response to compensate for this. See jitsu --help for a full list of available options.

Linux VMs in Virtualbox

Jitsu can be used to control VMs in Virtualbox with libvirt. Note that how well this will work depends on how quickly the VM is able to respond to requests after resuming from suspend (see also the -d parameter for how to delay the DNS response).

First, install libvirt and use virsh to display a list of available VMs. Example output:

$ virsh list --all
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 2     Ubuntu                         running

If virsh is unable to connect to Virtualbox, you may have to adjust the connection URI (-c [uri]). The default connection URI for Virtualbox is vbox:///session - see this page for more details. In OS X you may have to set the socket manually, which can be done with 'vbox:///session?socket=path-to-socket'. Remember to use the same connection URI for Jitsu below.

You should now be able to start Jitsu. Use '-m suspend' to set it to suspend the VM on inactivity. Example output:

$ sudo ./jitsu dns=www.example.com,ip=127.0.0.1,name=Ubuntu -m suspend -c vbox:///session
Connecting to vbox:///session...
Adding domain 'www.example.com' for VM 'Ubuntu' with ip 127.0.0.1
Adding SOA 'example.com' with ttl=60
Adding A PTR for 'www.example.com' with ttl=60 and ip=127.0.0.1
Starting server on 127.0.0.1:53...

To test that Jitsu works, try to resolve the domain with host:

$ host www.example.com 127.0.0.1
Using domain server:
Name: 127.0.0.1
Address: 127.0.0.1#53
Aliases:

www.example.com has address 127.0.0.1

The domain should now be running.

$ virsh dominfo Ubuntu
Id:             2
Name:           Ubuntu
UUID:           6e696eb7-09f4-484c-981b-8d34efa0304d
OS Type:        hvm
State:          running
CPU(s):         3
Max memory:     2147483648 KiB
Used memory:    3166208 KiB
Persistent:     yes
Managed save:   unknown

After 2 minutes without DNS requests, Jitsu will suspend the domain automatically. This timeout can be adjusted with the --ttl parameter. Jitsu terminates the VM after 2 x DNS TTL seconds has expired without new requests.

Options

    -b ADDR, --bind=ADDR (absent=127.0.0.1)
        Bind local DNS server to interface with this IP

    -c CONNECT, --connect=CONNECT (absent=xen:///)
        Libvirt and Xapi connection string (e.g. xen+ssh://x.x.x.x/system
        or vbox:///session)

    -d SECONDS, --delay=SECONDS (absent=0.1)
        Time to wait in seconds before responding to a DNS query after the
        local VM has started. This delay gives the VM time to open up the
        necessary TCP ports etc. Setting this value too low can result in
        long delays on the first TCP request to the VM.

    -f ADDR, --forwarder=ADDR
        IP address of DNS server queries should be forwarded to if no local
        match is found. Defaults to system default (/etc/resolv.conf) if
        not specified. Set to 0.0.0.0 to disable forwarding.

    --help[=FMT] (default=pager)
        Show this help in format FMT (pager, plain or groff).

    -l PORT, --listen=PORT (absent=53)
        UDP port to listen for DNS queries

    -m MODE, --mode=MODE (absent=destroy)
        How to stop running VMs after timeout. Valid options are suspend,
        destroy and shutdown. Suspended VMs are generally faster to resume,
        but require resources to store state. Note that MirageOS
        suspend/resume is currently not supported on ARM.

    -p PORT, --port=PORT (absent=53)
        UDP port to forward DNS queries to

    --persistdb=path
        Store the Irmin database in the specified path. The default is to
        store the database in memory only. Note that modifying this
        database while Jitsu is running is currently unsupported and may
        crash Jitsu or have other unexpected results.

    --synjitsu=UUID
        UUID of a running Synjitsu compatible unikernel. When specified,
        Jitsu will attempt to connect to a Synjitsu unikernel over Vchan on
        port 'synjitsu' and send notifications with updates on MAC- and
        IP-addresses of booted unikernels. This allows Synjitsu to send
        gratuitous ARP on behalf of booting unikernels and to cache
        incoming SYN packets until they are ready to receive them. This
        feature is experimental and requires a patched MirageOS TCP/IP
        stack.

    -t SECONDS, --ttl=SECONDS (absent=60)
        DNS TTL in seconds. The TTL determines how long the clients may
        cache our DNS response. VMs are terminated after no DNS requests
        have been received for TTL*2 seconds.

    --version
        Show version information.

    -x BACKEND, --backend=BACKEND (absent=libvirt)
        Which backend to use. Currently libvirt, xapi and libxl are
        supported. Xapi and libxl are less tested and should be considered
        experimental.

COMMON CONFIGURATION
    response_delay
        Override default DNS query response delay for this unikernel. See
        also -d.

    wait_for_key
        Wait for this key to appear in Xenstore before responding to the
        DNS query. Sleeps for [response_delay] after the key appears. The
        key should be relative to /local/domain/[domid]/.

    use_synjitsu
        Enable Synjitsu for this domain if not 0 or absent (requires
        Synjitsu support enabled)

LIBVIRT CONFIGURATION
    name
        Name of VM defined in libvirt (ignored if uuid is set)

    uuid
        UUID of VM defined in libvirt (required, but optional if name is
        set)

    dns DNS name (required)

    ip  IP to return in DNS reply (required)

XAPI CONFIGURATION
    name
        Name of VM defined in Xapi (ignored if uuid is set)

    uuid
        UUID of VM defined in Xapi (optional if name is set)

    dns DNS name (required)

    ip  IP to return in DNS reply (required)

LIBXL CONFIGURATION
    name
        Name of created VM (required)

    dns DNS name (required)

    ip  IP to return in DNS reply (required)

    kernel
        VM kernel file name (required)

    memory
        VM memory in bytes (required)

    cmdline
        Extra parameters passed to kernel (optional)

    nic Network device (br0, eth0 etc). Can be set more than once to
        configure multiple NICs (optional)

    script
        Virtual interface (VIF) configuration script. Can be set more than
        once to specify a VIF script per network device (optional)

    disk
        Disk to connect to the Xen VM. Format '[dom0
        device/file]@[hdX/xvdX/sdX etc]'. Can be set more than once to
        configure multiple disks (optional)

    rumprun_config
        Path to file with rumprun unikernel JSON config (optional)

License

Copyright (c) 2014-2015 Magnus Skjegstad <[email protected]> and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

More Repositories

1

mirage

MirageOS is a library operating system that constructs unikernels
OCaml
2,520
star
2

irmin

Irmin is a distributed database that follows the same design principles as Git
OCaml
1,742
star
3

ocaml-cohttp

An OCaml library for HTTP clients and servers using Lwt or Async
OCaml
644
star
4

alcotest

A lightweight and colourful test framework
OCaml
447
star
5

ocaml-git

Pure OCaml Git format and protocol
OCaml
349
star
6

mirage-tcpip

TCP/IP networking stack in pure OCaml, using the Mirage platform libraries. Includes IPv4/6, ICMP, and UDP/TCP support.
OCaml
321
star
7

mirage-skeleton

Examples of simple MirageOS apps
OCaml
224
star
8

qubes-mirage-firewall

A Mirage firewall VM for QubesOS
OCaml
207
star
9

mirage-www

Website infrastructure and content for mirage.io
HTML
162
star
10

decompress

Pure OCaml implementation of Zlib.
OCaml
116
star
11

ocaml-cow

Caml on the Web (COW) is a set of parsers and syntax extensions to let you manipulate HTML, CSS, XML, JSON and Markdown directly from OCaml code.
OCaml
105
star
12

awa-ssh

Purely functional SSH library in ocaml.
OCaml
104
star
13

ocaml-cstruct

Map OCaml arrays onto C-like structs
OCaml
103
star
14

ocaml-dns

OCaml implementation of the DNS protocol
OCaml
102
star
15

ocaml-solo5

Freestanding OCaml runtime
C
101
star
16

ocaml-github

GitHub APIv3 OCaml bindings
OCaml
100
star
17

capnp-rpc

Cap'n Proto RPC implementation
OCaml
97
star
18

ocaml-rpc

Light library to deal with RPCs in OCaml
OCaml
95
star
19

ocaml-uri

RFC3986 URI parsing library for OCaml
OCaml
93
star
20

digestif

Simple hash algorithms in OCaml
OCaml
88
star
21

ocaml-conduit

Dereference URIs into communication channels for Async or Lwt
OCaml
84
star
22

mirage-crypto

Cryptographic primitives for OCaml, in OCaml (also used in MirageOS)
C
77
star
23

mirage-platform

Archived, see https://github.com/mirage/mirage/issues/1159 for details. Old: Core platform libraries for Mirage (UNIX and Xen). This provides the `OS` library which handles timers, device setup and the main loop, as well as the runtime for the Xen unikernel.
C
77
star
24

xen

Unofficial mirror of xenbits.xen.org/xen.git
C
72
star
25

ocaml-crunch

Convert a filesystem into a static OCaml module
OCaml
70
star
26

ocaml-9p

An OCaml/Mirage-friendly implementation of the 9P protocol
OCaml
63
star
27

functoria

A DSL to invoke otherworldly functors
OCaml
63
star
28

mini-os

Mirror of the Xen MiniOS Git from git://xenbits.xen.org/mini-os.git
C
63
star
29

mirage-qubes

Mirage support for writing QubesOS AppVM unikernels
OCaml
62
star
30

xen-arm-builder

Archived - the Xen and ARM support in MirageOS has been superseeded by our PVH support - Build an SDcard image for Xen/ARM, for a Cubieboard
Shell
57
star
31

charrua

A DHCP library in OCaml
OCaml
55
star
32

orm

Object Relational Mapper extension
OCaml
54
star
33

ke

Fast implementation of queue in OCaml
HTML
52
star
34

eqaf

Constant time equal function to avoid timing attacks in OCaml
OCaml
51
star
35

conan

Like detective conan, find clue about the type of the file
OCaml
49
star
36

prometheus

OCaml library for reporting metrics to a Prometheus server
OCaml
49
star
37

ocaml-matrix

Implementation of a matrix server in OCaml for MirageOS
OCaml
49
star
38

ocaml-tar

Pure OCaml library to read and write tar files
OCaml
49
star
39

ocaml-vchan

Pure OCaml implementation of the "vchan" shared-memory communication protocol
OCaml
46
star
40

metrics

Infrastructure to collect metrics from OCaml applications.
OCaml
46
star
41

bechamel

Agnostic benchmark in OCaml (proof-of-concept)
OCaml
44
star
42

wodan

A Mirage filesystem library
OCaml
44
star
43

ocaml-base64

Base64 encoding and decoding in OCaml
OCaml
43
star
44

colombe

Implementation of SMTP protocols in OCaml
OCaml
42
star
45

ocaml-ipaddr

A library for manipulation of IP (and MAC) address representations
OCaml
40
star
46

mrmime

What do you mean?
OCaml
40
star
47

ezjsonm

An easy interface on top of the Jsonm library.
OCaml
40
star
48

index

A platform-agnostic multi-level index
OCaml
34
star
49

bloomf

Efficient Bloom filters for OCaml
OCaml
34
star
50

emile

& images
OCaml
31
star
51

mirage-nat

library for network address translation intended for use with mirage unikernels
OCaml
31
star
52

repr

OCaml
31
star
53

ocaml-hex

Hexadecimal converter
OCaml
29
star
54

ocaml-diet

A simple implementation of Discrete Interval Encoding Trees
OCaml
28
star
55

ptt

Postes, Télégraphes et Téléphones
OCaml
26
star
56

ocaml-fat

Read and write FAT format filesystems from OCaml
OCaml
26
star
57

encore

Synonym of angkor
OCaml
25
star
58

ocaml-magic-mime

Convert file extensions to MIME types
OCaml
24
star
59

irmin-server

A high-performance server for Irmin
OCaml
24
star
60

optint

Library to provide a fast integer (x64 arch) or allocated int32 (x84 arch)
OCaml
24
star
61

ocaml-lazy-trie

Lazy prefix trees in OCaml
OCaml
23
star
62

qubes-mirage-skeleton

An example Mirage unikernel that runs as a Qubes AppVM
OCaml
23
star
63

ocaml-pcap

OCaml code for generating and analysing pcap (packet capture) files
OCaml
22
star
64

duff

Pure OCaml implementation of libXdiff (Rabin's fingerprint)
OCaml
21
star
65

hacl

Archived. Curve25519 support has been integrated into mirage-crypto-ec (via fiat-crypto). Hacl bindings are available from the hacl-star opam package. OCaml bindings for HACL* elliptic curves
C
21
star
66

arp

Address resolution protocol (ARP) implementation in OCaml targeting MirageOS
OCaml
21
star
67

shared-memory-ring

Xen-style shared memory rings
OCaml
20
star
68

irmin-rpc

RPC client/server for Irmin
OCaml
20
star
69

typebeat

Parsing of the Content-Type header in pure OCaml
OCaml
20
star
70

mirage-solo5

Solo5 core platform libraries for MirageOS
OCaml
20
star
71

ocaml-tuntap

Bindings to UNIX tuntap facilities
OCaml
20
star
72

mirage-lambda

An eDSL for MirageOS apps
OCaml
19
star
73

merge-queues

Mergeable queues
OCaml
19
star
74

ocaml-qcow

Pure OCaml code for parsing, printing, modifying .qcow format data
OCaml
19
star
75

ocaml-vmnet

NATed networking on MacOS X using the vmnet framework
OCaml
18
star
76

mirage-xen

Xen core platform libraries for MirageOS
C
18
star
77

mirage-profile

Collect profiling information
OCaml
18
star
78

cactus

A Btree library in OCaml
OCaml
18
star
79

mirage-clock

Portable clock implementation for Unix and Xen
OCaml
18
star
80

ocaml-mbr

A simple library for manipulating Master Boot Records
OCaml
18
star
81

spamtacus

Ocaml modular spam filter
OCaml
16
star
82

mirage-dev

Development OPAM repository for work-in-progress packages
16
star
83

ocaml-fsevents

macOS bindings to the FSEvents API
OCaml
16
star
84

mirage-fs-unix

Unix Filesystem passthrough for MirageOS
OCaml
16
star
85

mirage-vnetif

Virtual network interface and software bridge for Mirage
OCaml
16
star
86

irmin-rs

Rust
15
star
87

ocaml-hvsock

Bindings for hypervisor sockets, for Linux, Windows and macOS (via Hyperkit)
OCaml
15
star
88

ca-certs

Detect root CA certificates from the operating system
OCaml
15
star
89

irmin-watcher

Portable implementation of the Irmin Watch API
OCaml
15
star
90

checkseum

C
15
star
91

mirage-handbook

WIP Handbook for MirageOS
14
star
92

retreat.mirage.io

Microsite for the MirageOS hack retreats
OCaml
14
star
93

mmap

File mapping
OCaml
13
star
94

mirage-decks

These are the MirageOS slide decks, written as a self-hosting unikernel
HTML
13
star
95

ezxmlm

Like the tax form, this is an easier interface for quick n dirty XMLM scripts
OCaml
13
star
96

mirage-unix

Unix core platform libraries for MirageOS
OCaml
13
star
97

ocaml-gpt

A simple library for manipulating GUID partition tables
OCaml
12
star
98

irmin.org

Irmin website
CSS
12
star
99

mirage-console

Portable console handling for Mirage applications
OCaml
12
star
100

mirage-net-xen

Xen Netfront and Netback ethernet device drivers for Mirage
OCaml
12
star