Make nova-compute-network use a data volume container

A data volume container is far superior to bind mounting the
host's shared directories.  It preserves the idempotency,
immutability and declarative properties of the containers.

The way this works in practice is that a data volume container is
created.  Then when the containers start they use LVM to access
the filesystem where /var/lib/docker is contained.  Then the
container startup logic bindmounts the data volume stored on the
host filesystem in /var/lib/docker/vfs/dir/ID.  This prevents
people with access to the host operating system from damaging
the contents of the data container.

It does mean that now we must use tools/stop to stop our containers
rather than tools/cleanup-containers -f.

This is a containers best practice.  For more details see:

https://docs.docker.com/userguide/dockervolumes/

Big credit goes to Danyeon Hansen for seeding this idea in the
mariadb containers.

Note occasionally docker-compose start/stop seems to not want to stop
a container.  This bug needs to be addressed upstream separately
from our utilization of this best practice.

Change-Id: Iaa1419f606e1b1b7a7560a095c49e79d643164f1
This commit is contained in:
Steven Dake 2015-03-21 15:13:32 -07:00
parent 3f036e3f93
commit f4fd47dc2c
6 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,7 @@
computedata:
image: kollaglue/centos-rdo-nova-compute-data
name: computedata
libvirt: libvirt:
image: kollaglue/centos-rdo-nova-libvirt image: kollaglue/centos-rdo-nova-libvirt
name: libvirt name: libvirt
@ -10,9 +14,8 @@ libvirt:
volumes: volumes:
- /run:/run - /run:/run
- /sys/fs/cgroup:/sys/fs/cgroup - /sys/fs/cgroup:/sys/fs/cgroup
- /var/lib/nova:/var/lib/nova volumes_from:
- /var/lib/libvirt:/var/lib/libvirt - computedata
- /etc/libvirt/qemu:/etc/libvirt/qemu
novanetwork: novanetwork:
image: kollaglue/centos-rdo-nova-network image: kollaglue/centos-rdo-nova-network
@ -25,8 +28,8 @@ novanetwork:
volumes: volumes:
- /run:/run - /run:/run
- /sys/fs/cgroup:/sys/fs/cgroup - /sys/fs/cgroup:/sys/fs/cgroup
- /var/lib/nova:/var/lib/nova volumes_from:
- /var/lib/libvirt:/var/lib/libvirt - computedata
novacompute: novacompute:
image: kollaglue/centos-rdo-nova-compute image: kollaglue/centos-rdo-nova-compute
@ -39,6 +42,5 @@ novacompute:
volumes: volumes:
- /run:/run - /run:/run
- /sys/fs/cgroup:/sys/fs/cgroup - /sys/fs/cgroup:/sys/fs/cgroup
- /var/lib/nova:/var/lib/nova volumes_from:
- /var/lib/libvirt:/var/lib/libvirt - computedata
- /etc/libvirt/qemu:/etc/libvirt/qemu

View File

@ -0,0 +1,10 @@
FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base
MAINTAINER Kolla Project (https://launchpad.net/kolla)
VOLUME [ "/var/lib/nova" ]
VOLUME [ "/var/lib/libvirt" ]
VOLUME [ "/etc/libvirt/qemu" ]
# Command needed to start the data container.
# Note: data containers do not need to be persistent.
CMD ["/bin/true"]

View File

@ -0,0 +1 @@
../../../tools/build-docker-image

View File

@ -9,7 +9,5 @@ ADD config-nova-compute.sh /opt/kolla/config-nova-compute.sh
ADD ./start.sh /start.sh ADD ./start.sh /start.sh
VOLUME [ "/sys/fs/cgroup" ] VOLUME [ "/sys/fs/cgroup" ]
VOLUME [ "/var/lib/nova" ]
VOLUME [ "/var/lib/libvirt" ]
CMD ["/start.sh"] CMD ["/start.sh"]

View File

@ -6,7 +6,6 @@ RUN yum -y install libvirtd libguestfs qemu-system-x86 \
libvirt-daemon-config-nwfilter; yum clean all libvirt-daemon-config-nwfilter; yum clean all
VOLUME [ "/sys/fs/cgroup" ] VOLUME [ "/sys/fs/cgroup" ]
VOLUME [ "/var/lib/nova" ]
ADD ./start.sh /start.sh ADD ./start.sh /start.sh

View File

@ -7,7 +7,4 @@ RUN yum -y install openstack-nova-network \
ADD config-nova-network.sh /opt/kolla/config-nova-network.sh ADD config-nova-network.sh /opt/kolla/config-nova-network.sh
ADD ./start.sh /start.sh ADD ./start.sh /start.sh
VOLUME [ "/var/lib/nova" ]
VOLUME [ "/var/lib/libvirt" ]
CMD ["/start.sh"] CMD ["/start.sh"]