From a1a23998405c81a2ee7b5df19570858bcb584d31 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 22 Jan 2019 15:44:50 -0500 Subject: [PATCH] lxc lightning? talk notes Signed-off-by: Bill Erickson --- lxc.adoc | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 lxc.adoc diff --git a/lxc.adoc b/lxc.adoc new file mode 100644 index 000000000..81f94656c --- /dev/null +++ b/lxc.adoc @@ -0,0 +1,73 @@ += Linux Containers For Developers +:author: Bill Erickson, Software Development Engineer, King County Library System +:email: berickxx@gmail.com +:date: Evergreen Conference 2019 +:duration: 5 +:backend: slidy +:max-width: 45em +:deckjs_theme: web-2.0 + +== LXC & LXD + +* Run a separate Linux OS inside a sandbox +* Conceptually similar to Docker +* Supports snapshots, cloning, standard VM stuff +* https://blog.ubuntu.com/2016/03/22/lxd-2-0-your-first-lxd-container + +== Advantages over VMs + +* Requires fewer resources -- no virtualization layer. +* Works fine with network aliases + lxd routing (or iptables) +** Network bridging is not required to act as a server. +* Very fast boot times +* Direct file copy to/from image rootfs +* You can run Evergreen on a Chromebook! + +== Limitations + +* Linux only +* Some commands cannot be run (e.g. sysctl) + +== Create a Disk (OPTIONAL) + +* Many ways to do this. +* ZFS and btrfs recommended +** https://lxd.readthedocs.io/en/latest/storage/ + +[source,sh] +-------------------------------------------------------------------------- +lxc storage create pool1 btrfs source=/VM +-------------------------------------------------------------------------- + +== Init LXD and Create an Image + +[source,sh] +-------------------------------------------------------------------------- +sudo lxd init # tell it about the storage pool +sudo lxc launch ubuntu:16.04 eg-dev +sudo lxc exec eg-dev -- bash +-------------------------------------------------------------------------- + +== Route Web Requests + +* Add a network alias on the host of (for example) 10.0.0.50 +* Relay requests against the alias address to the image + +[source,sh] +-------------------------------------------------------------------------- +sudo lxc config device add eg-dev eg-dev-port80 proxy \ + listen=tcp:10.0.0.50:80 connect=tcp:localhost:80 +sudo lxc config device add eg-dev eg-dev-port443 proxy \ + listen=tcp:10.0.0.50:443 connect=tcp:localhost:443 +-------------------------------------------------------------------------- + +== Snapshots and Cloning + +[source,sh] +-------------------------------------------------------------------------- +sudo lxc snapshot eg-dev snap0-base # create +sudo lxc restore eg-dev snap0-base # roll back to snapshot +sudo lxc copy eg-dev/snap0-base eg-dev-2 # clone from snapshot +-------------------------------------------------------------------------- + + -- 2.11.0