From 5994dd3f37145771ae4521686880c22cbe541733 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 2 Apr 2019 11:36:55 -0400 Subject: [PATCH] lxc lightning Signed-off-by: Bill Erickson --- lxc.adoc | 26 +- lxc.html | 3993 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 4006 insertions(+), 13 deletions(-) create mode 100644 lxc.html diff --git a/lxc.adoc b/lxc.adoc index 32411886d..fb5fdd5bf 100644 --- a/lxc.adoc +++ b/lxc.adoc @@ -1,4 +1,4 @@ -= Linux Containers For Developers += Linux Containers :author: Bill Erickson, Software Development Engineer, King County Library System :email: berickxx@gmail.com :date: Evergreen Conference 2019 @@ -14,32 +14,32 @@ * Supports snapshots, cloning, standard VM stuff * https://blog.ubuntu.com/2016/03/22/lxd-2-0-your-first-lxd-container -== Advantages over VMs +== Advantages -* 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. +* Process run natively / no virtualization + ** Requires fewer resources + ** Process appear in process list / top +* Handles network bridging / routing tools * Very fast boot times -* Direct file copy to/from image rootfs * You can run Evergreen on a Chromebook! == Limitations * Linux only -== Create a Disk (OPTIONAL) +== Many Disk Options -* Many ways to do this. -* ZFS and btrfs recommended -** https://lxd.readthedocs.io/en/latest/storage/ -* ZFS is more stable and easier to set up. +* ZFS and btrfs offer most functionality. +* ZFS is more mature and easier to set up. == Init LXD and Create an Image [source,sh] -------------------------------------------------------------------------- sudo lxd init # create new zfs pool from a partition + sudo lxc launch ubuntu:16.04 eg-dev + sudo lxc exec eg-dev -- bash -------------------------------------------------------------------------- @@ -50,8 +50,6 @@ sudo lxc exec eg-dev -- bash [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 -------------------------------------------------------------------------- @@ -61,7 +59,9 @@ sudo lxc config device add eg-dev eg-dev-port443 proxy \ [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 -------------------------------------------------------------------------- diff --git a/lxc.html b/lxc.html new file mode 100644 index 000000000..2b2e1640a --- /dev/null +++ b/lxc.html @@ -0,0 +1,3993 @@ + + + + +Linux Containers + + + + + + + + + +
+

LXC & LXD

+
+ +
+
+
+

Advantages

+
+
    +
  • + +Process run natively / no virtualization + +
      +
    • + +Requires fewer resources + +
    • +
    • + +Process appear in process list / top + +
    • +
    +
  • +
  • + +Handles network bridging / routing tools + +
  • +
  • + +Very fast boot times + +
  • +
  • + +You can run Evergreen on a Chromebook! + +
  • +
+
+
+
+

Limitations

+
+
    +
  • + +Linux only + +
  • +
+
+
+
+

Many Disk Options

+
+
    +
  • + +ZFS and btrfs offer most functionality. + +
  • +
  • + +ZFS is more mature and easier to set up. + +
  • +
+
+
+
+

Init LXD and Create an Image

+
+
+
+
sudo lxd init # create new zfs pool from a partition
+
+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 + +
  • +
+
+
+
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

+
+
+
+
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