ContainersSpec
Launchpad Entry: server-lucid-contextualization
Created: 2009-11-26
Contributors: SorenHansen
Packages affected:
Summary
Containers offer a simple way to confine processes to a particular namespace. LXC is the container technology in the upstream kernel, and it provides an excellent upgrade path for people using the openvz kernel we had in Hardy. It does not require special hardware support, so in situations where kvm doesn't work it might offer people a saner alternative to Xen
Release Note
Ubuntu 9.10 offers container based virtualisation. LXC, the container technology in Linux, offers a lightweight way to subdivide system ressources, while still allowing each subdivision full control (root access) to its part of the system. This can be used to provide very high density "virtual machines" with very little effort.
Rationale
LXC is in the upstream kernel. It's very useful, and the amount of work to make it work in Ubuntu is minimal.
User stories
Stéphane used the OpenVZ kernel shipped in Hardy. With a new LTS coming out he would like to upgrade, but we no longer ship an OpenVZ kernel. He migrates his OpenVZ setup to LXC by ... XXX
- Soren has an old machine that does not support KVM. He does not enjoy Xen, and being an Ubuntu fanatic, all his VM's are Ubuntu based anyway, so he uses LXC containers as a simple and high-performance solution.
- Lamont manages the Ubuntu buildd's. Builds are traditionally run in chroots, but containers offer better isolation, so he wants to use it as a drop-in replacement for chroot.
Design
Upstream libvirt already supports LXC. We should make sure this support is enabled and working properly.
LXC support in libvirt is currently broken due to apparmour being too restrictive
- Libvirt needs to be built against libcap-ng to be able to drop certain CAPabilities (thus properly containing the containers).
We will make it easier to build containers by adding LXC support to VM builder.
Perhaps we should provide ready made containers for people to use if they're running other host OS's? XXX
Implementation
See work items in status whiteboard.
Test/Demo Plan
tbd.
Unresolved issues
None.
BoF agenda and discussion
UDS discussion notes
While regular virtualization (kvm/virtualbox/vmware/...) is great, it still has to virtualize a whole computer including the BIOS and run its own kernel.
In most cases, it's not necessary and having some kind of "chroot" with quota on main resources (CPU, memory, network, disk) would be enough. That's what contextualization technologies let you do, the most known of which is probably OpenVZ (virtuoso) but Vserver and LXC also exist.
LXC is the mainline implementation of contextualization and is built-in the kernel since 2.6.28 and well working as of 2.6.31. It would be interesting that the next LTS (10.04) supports both virtualization and contextualization and so will cover everybody's needs.
Notes
- stefan's ubuntu desktop is running in an LXC container
- no graphics hardware available in LXC, uses NX for desktop access
- Typical usage is dozens/hundreds of containers on one server. Each service (apache, postfix, etc) is isolated into its own container. Each container has root access, but no device access, so it's relatively secure.
- File access is from a directory on the host. You can mount a loopback, etc.
- Host can see all processes in ps; guests can only see their own
- e.g. host sees 2 init processes, guest sees only 1 (and thinks it's process 1)
- /dev is relatively bare
- e.g. there's loop0, shm, urandom, zero, etc, but not the rest of the real hardware devices
- It is however possible to give access to some devices by mknod and granting access to the container. For example, an asterisk server could access a telephony card.
- Upstream KVM is looking at launching KVM's in containers
- namespace
- security
- resource constraints
Use Cases for Containers
- ltsp
- canonical buildd's currently use chroots
- some of canonical xen guests could be containers
- ISP's are well suited to containers
- Eucalyptus interacts with the hypervisor entirely through libvirt
- could potentially have container machine types
- need to investigate dynamic block attach
- seems that this should be easy to do, actually
- block device names would need to match ec2 semantics
- KVM + LXC on same host
- LXC inside a KVM guest
- Package installation/upgrade testing
- for i in contexts;do (in context) apt-get upgrade;done
- 64bit ubuntu install with a 32bit ubuntu container
ACTIONS
- Bug: #480739
- Kernel config options that need to be turned on CONFIG_CGROUP_DEVICE=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
- Need to talk to the kernel team to do this
- Might introduce some overhead to baremetal server kernels
- can be disabled by boot option "noswapaccount" and there will be no overhead.
- vm-builder would need to be able to bootstrap a container (soren)
- soren "accidentally" implemented this last week
- libvirt needs to build against libcapng
- need to sync libcapng from Debian
- Could port userspace lxc to main
- enhance libvirt apparmor for lxc coverage (jdstrand)
ContainersSpec (last edited 2009-11-30 11:26:24 by eth0)