Slide 1

Slide 1 text

Jetpack Container runtime for FreeBSD Maciej Pasternacki 
 Berlin DevOps 2015-01 3ofcoins @mpasternacki

Slide 2

Slide 2 text

1. OS-level virtualization across the ages 2. The container paradigm 3. Docker, Rocket, and breaking the monoculture 4. Jetpack: motivation, implementation, demo

Slide 3

Slide 3 text

OS-level virtualization – Single host kernel, multiple isolated guest user spaces – Not as universal as full virtualization – Very small overhead – Resources can be shared between instances – Adjustable isolation level

Slide 4

Slide 4 text

CHROOT(2) FreeBSD System Calls Manual CHROOT(2) ! NAME chroot — change root directory ! LIBRARY Standard C Library (libc, -lc) ! SYNOPSIS #include ! int chroot(const char *dirname); ! DESCRIPTION The dirname argument is the address of the pathname of a directory, ter‐ minated by an ASCII NUL. The chroot() system call causes dirname to become the root directory, that is, the starting point for path searches of pathnames beginning with ‘/’. 1982: Stone Age

Slide 5

Slide 5 text

1998-2012: Industrial Age – 1998: FreeBSD Jail – 2001: Linux-VServer, Virtuozzo – 2005: OpenVZ, Solaris Containers – 2008: Linux cgroups, LXC

Slide 6

Slide 6 text

1998-2012: Industrial Age – Isolated filesystem, process tree, networking – Restricted interaction between environments – Restricted administrative system calls – Resource usage limits

Slide 7

Slide 7 text

VM Mindset Guest is a complete system: – managed from the inside – runs multiple services – long-running and mutable – opaque to host Management overhead of a whole server

Slide 8

Slide 8 text

2013: Modern Age – Jan 2013: Docker – Dec 2014: CoreOS Rocket, App Container Specification – Jan 2015: Jetpack

Slide 9

Slide 9 text

2013: Modern Age – Inspired by PaaS, application-focused – Guest managed from the outside – Immutable, distributable images – Fast copy-on-write provisioning

Slide 10

Slide 10 text

Container Mindset – Layered storage – Explicit interaction points – Immutable images, volatile containers – Service-oriented

Slide 11

Slide 11 text

Layered Storage Ubuntu LTS Ruby-2.1.5 Redis server Rails app Sinatra app Alice's App Bob's App Claire's App Redis A Redis B Redis C User Uploads User Uploads Persistence Persistence Persistence Image (RO) Container (R/W, volatile) Volume (persistent)

Slide 12

Slide 12 text

Interaction Points – Command line arguments – Environment variables – Network ports – Persistent volumes – Stdin, stdout, stderr – Exit status

Slide 13

Slide 13 text

Immutability – Images, once built, are read-only – Containers’ write layer is throwaway – Volumes are persistent

Slide 14

Slide 14 text

Immutability – Images, once built, can be repeatably reused – Containers are exchangeable (upgrades!) – Volumes declare user data

Slide 15

Slide 15 text

Service-oriented – Well-defined images can be shared and reused across applications – Containers can be meaningfully managed and monitored by host – Management overhead of a service rather than whole machine

Slide 16

Slide 16 text

Docker – First free container runtime – Defined the paradigm – Extremely fast and wide adoption – Runs on Linux – Implementation-driven https://www.docker.com/

Slide 17

Slide 17 text

Docker – Only free container runtime, until recently – Prototyped the paradigm – Extremely soon locked into early decisions – Tied to Linux – Implementation-defined https://www.docker.com/

Slide 18

Slide 18 text

The management question, therefore, is not whether to build a pilot system and throw it away. You will do that. […] Hence plan to throw one away; you will, anyhow. (Fred Brooks, The Mythical Man-Month)

Slide 19

Slide 19 text

Rocket – New container runtime by CoreOS – Designed for “composability, security, and speed” (also simplicity & interoperability) – Implementation follows (neutral) specification – Breaks Docker monoculture – Runs on Linux (uses systemd heavily) https://coreos.com/blog/rocket/

Slide 20

Slide 20 text

App Container Specification The "App Container" defines an image format, image discovery mechanism and execution environment that can exist in several independent implementations. https://github.com/appc/spec

Slide 21

Slide 21 text

Jetpack – (incomplete) App Container implementation for FreeBSD – Written in Go – Jails for process isolation & lockdown – ZFS for layered storage – Breaks Linux monoculture (hopefully) https://github.com/3ofcoins/jetpack/

Slide 22

Slide 22 text

Jetpack: ZFS storage – Snapshots/clones for layered storage – Deduplication & compression conserves space – Streaming allows easy distribution of complete set of images https://github.com/3ofcoins/jetpack/

Slide 23

Slide 23 text

Jetpack: Building Images jetpack image IMG build -dir=. COMMAND… 1. clone new container from IMG 2. copy build dir -dir to container 3. run COMMAND… inside container, in build dir 4. commit container’s rootfs without build dir as new image https://github.com/3ofcoins/jetpack/

Slide 24

Slide 24 text

Jetpack: Building Images jetpack image IMG build -dir=. COMMAND… – COMMAND is toolchain-agnostic, it can be:
 ./setup.sh, make build, chef-solo… – Doesn’t introduce a new file format – A bsdmake include file is provided, but not required https://github.com/3ofcoins/jetpack/

Slide 25

Slide 25 text

jetpack.image.mk – Makefile include to simplify image building – Prepares build dir on host – jetpack image … build make build https://github.com/3ofcoins/jetpack/

Slide 26

Slide 26 text

jetpack.image.mk https://github.com/3ofcoins/jetpack/ .MAKEFLAGS: -I/usr/local/share/jetpack ! PARENT_IMAGE = freebsd-base PKG_INSTALL = nginx ! build: # this runs after package is installed install -v -m 0640 -o root -g www \ nginx.conf /usr/local/etc/nginx.conf ! manifest.json: ./manifest.json.sh > $@ ! .include "jetpack.image.mk"

Slide 27

Slide 27 text

https://github.com/3ofcoins/jetpack/ PARENT_IMAGE = freebsd-base/release$(RELEASE) CLEAN_FILES = entropy manifest.json BUILD_VARS = http_proxy ! prepare: # this runs on host to prepare build dir dd if=/dev/random of=entropy bs=4096 count=1 ! build: sed -i '' 's|^Components.*|Components world/base|' \ /etc/freebsd-update.conf install -v -m 0644 rc.conf /etc/rc.conf install -v -m 0600 entropy /entropy PAGER=cat freebsd-update -s update6.freebsd.org \ fetch install rm -rf /var/db/freebsd-update/* ! manifest.json: ./manifest.json.sh > $@

Slide 28

Slide 28 text

Jetpack: The Future – Complete spec coverage – Network stack separation (VIMAGE) – Resource limiting (RCTL) – Firewall/NAT rules management (pf) – Image discovery & distribution – A LOT MORE… it’s still a prototype! https://github.com/3ofcoins/jetpack/

Slide 29

Slide 29 text

Demo Time!

Slide 30

Slide 30 text

https://github.com/3ofcoins/jetpack/ ➳ https://github.com/appc/spec/ ➳ https://coreos.com/blog/rocket/ ➳ http://3ofcoins.net/2014/12/06/of-containers- dockers-rockets-and-daemons/ ➳ https://www.docker.com/ ➳ http://cryptome.org/cyberinsecurity.htm