Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Linux Containers (LXC) is a lightweight system virtualization that uses resource isolation instead of the hardware emulation approach used by KVM and Xen. For users who do not require full OS virtualization as provided by KVM and Xen, container technologies such as LXC provide an attractive performant solution for virtualization.

Cloudstack currently does not support containers such as LXC and OpenVZ.

Purpose

This docoument contains the design specification for LXC support in Cloudstack.

References

...

Status

Code complete, feature has been merged to master branch.

References

...

...

...

Feature Specification

LXC will be implemented as a hypervisor in Cloudstack and will be a first class citizen to the other hypervisors such as Xen, KVM, VMWare. As such, a user will be able to select LXC as the hypervisor for all areas a hypervisor is selectable and where the system resources have been met.

Primary storage

Available storage options for LXC primary storage are NFS and SharedMountPoint.

Secondary storage

Unlike other hypervisors where a VM is contained in a single image file, LXC containers run from a directory that serves as the root filesystem. LXC template images will be stored in TAR format in secondary storage. See LXC Templates section for details on how the image is unpacked.

Guest VM creation

Similar to KVM, LXC virtual machines will be created using libvirt. The libvirt domain xml will include two additional elements needed for LXC: <init> and <filesystem>.

...

During the creation of the first VM for an LXC template, the management server will send a PrimaryStorageDownload command to the agent on the LXC host. This command makes a copy of the template from from secondary storage onto primary storage. This copy is used as a base for creating all LXC images for the cluster and is not used directly to run a VM. The copy operation from secondary storage to primary storage will unpack the tar file into the destination template directory.

...

Code Block
bash$ ls -ld /mnt/primary/*
     4 dr-xr-xr-x. 23 root root      4096 Jan 25 11:33 2cc4e71e-2e4b-4987-a48e-dfae08e0d767
     4 drwxr--r--. 23 root root      4096 Jan 25 13:27 edb596f6-42fb-499d-8ded-8834aff52d75

Secondary storage

LXC template images will be stored in TAR format. See LXC Templates section for details on how the image is unpacked.

Primary storage

Available storage options for LXC primary storage are NFS and SharedMountPoint

System VMs

Each of the different hypervisors currently have their own System VMs. These system VM images are used to run the a console proxy VM and the , secondary storage VM.

One proposal is to make the console proxy optional and run the secondary storage daemon on baremetal (next ot the management server)

API

TODO: investigate

Development/testing setup

Assuming you are familiar with setting up a development environment, here are additional things to note:

...

, and router VMs.

We discussed the possibility of creating System VMs for LXC. There was concern with the complexity and potential issues involving iptables for the router inside an LXC container. As an intermediate solution we are going to use KVM System VMs inside the LXC Cluster.

Direct Networking

Libvirt supports direct attachment of the guest VM's network to a physical interface. To enable this mode, add the following to agent.properties:

Code Block

libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver
network.direct.source.mode=private (other values: bridge|vepa)
network.direct.device=eth0

NOTE: The network device that is specified should not be a slave to any bridges.

Environment setup and testing

Obtaining latest code

The LXC code has been merged to the master branch for Cloudstack:

Code Block

git clone https://git-wip-us.apache.org/repos/asf/cloudstack.git

Follow directions in /docs/en-US/build-rpm.xml to build RPMs for Cloudstack.

Installing Cloudstack

I will not cover how to install Cloudstack, please use the latest online documents. There are a few things to note when using the LXC code:

1. Use the latest system VM images from Jenkins

Import the latest system VM image:

Code Block

/web/cloudstack/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary -u http://jenkins.cloudstack.org/view/master/job/build-systemvm-master/lastSuccessfulBuild/artifact/tools/appliance/dist/systemvmtemplate-2013-04-14-master-kvm.qcow2.bz2 -h kvm -F

2. LXC container

Cloudstack will not come bundled with an LXC container image, so you will need to prepare one yourself or download one.

...