Implement base container for LVM-backed CoW containers

This patch implements a base container which may be used by a
deployer to deploy copy-on-write container backing stores backed
by LVM.

This process may be used to speed up the container creation
process without compromising security through the user of
backing stores like overlayfs.

Change-Id: I0bf227891a85bd7c8db53ca73fc5380b95e514fa
This commit is contained in:
Jesse Pretorius 2016-08-21 19:08:44 +01:00
parent 5c58449026
commit b9c515a8a5
3 changed files with 40 additions and 1 deletions

View File

@ -31,6 +31,15 @@ lxc_container_cache_path: "/var/cache/lxc/download"
# which is when overlayfs was merged into the mainline kernel
# lxc_container_backing_store: overlayfs
# The container backing method can be set to 'copy-on-write' to use LVM
# snapshot-backed containers when the container backing store is set to
# 'lvm'.
# lxc_container_backing_method: copy-on-write
# When using a base container to snapshot from for the overlayfs or LVM
# copy-on-write backing stored, the base container can be set.
lxc_container_base_name: "{{ lxc_cache_map.distro }}-{{ lxc_cache_map.release }}-{{ lxc_cache_map.arch }}"
# lxc container net network
lxc_net_bridge: lxcbr0
lxc_net_bridge_port: none

View File

@ -0,0 +1,14 @@
---
features:
- The container cache preparation process now allows ``copy-on-write`` to be
set as the ``lxc_container_backing_method`` when the
``lxc_container_backing_store`` is set to ``lvm``. When this is set a base
container will be created using a name of the form
`<linux-distribution>`-`distribution-release>`-`<host-cpu-architecture>`.
The container will be stopped as it is not used for anything except to be
a backing store for all other containers which will be based on a snapshot
of the base container.
- When using copy-on-write backing stores for containers, the base container
name may be set using the variable ``lxc_container_base_name`` which
defaults to
`<linux-distribution>`-`distribution-release>`-`<host-cpu-architecture>`.

View File

@ -36,7 +36,7 @@
- name: Create base container to use for overlayfs containers
lxc_container:
name: "{{ lxc_cache_map.distro }}-{{ lxc_cache_map.release }}-{{ lxc_cache_map.arch }}"
name: "{{ lxc_container_base_name }}"
template: "download"
state: stopped
backing_store: "dir"
@ -48,3 +48,19 @@
when:
- lxc_container_backing_store is defined
- lxc_container_backing_store == 'overlayfs'
- name: Create base container to use for LVM-backed copy-on-write containers
lxc_container:
name: "{{ lxc_container_base_name }}"
template: "download"
state: stopped
backing_store: "lvm"
template_options: "{{ lxc_cache_download_template_options }}"
register: cache_download
retries: 3
delay: 10
until: cache_download|success
when:
- lxc_container_backing_store is defined
- lxc_container_backing_store == 'lvm'
- lxc_container_backing_method == 'copy-on-write'