how to configure lxc container on openstack newton

  • install required packages
apt update
apt install -y lxc nova-compute-lxc

  • load nbd module and add nbd to /etc/modules for boot-up loading
modprobe nbd

  • check that compute_driver is configured to that of lxc container
cat /etc/nova/nova-compute.conf

  • configure netwoking bridge for lxc
# no lxc-bridge but ovs
# modify USE_LXC_BRIDGE in /etc/default/lxc-net to false

  • create a container rootfs
sudo utm.tar.gz utmlxc 1GB

  • copy container rootfs to an appropriate directory
sudo cp utmlxc.tar.gz /var/vnf/images/

  • register the container image to glance
sudo glance --insecure image-create --name "utm-lxc" --disk-format raw \
            --container-format bare --visibility public \
            --property hypervisor_type=lxc --progress \
            --file /var/vnf/images/utmlxc.tar.gz

  • restart nova compute service
sudo service nova-compute restart

  • create flavor in command line, and set properties according to your needs
# you can also create flavor in openstack dashboard
# (i.e. id mem hdd cpu)
sudo nova flavor-create m1.small 6 4096 120 1 
sudo openstack flavor set m1.small --property hw:mem_page_size=large
sudo openstack flavor set m1.small --property hw:cpu_policy=dedicated
sudo openstack flavor set m1.small --property hw:cpu_thread_policy=prefer
sudo openstack flavor set m1.small --property hw:cpu_sockets=1

  • launch lxc instance, for example
sudo openstack server create --flavor m.small --image utm-lxc \
        --nic net-id=86af51d3-30ca-4dd8-869c-54de25209210 \
        --nic net-id=a791946a-0cb9-407d-81da-1450fe122259 \
        --nic net-id=f3eb3b1e-9424-477a-b900-c36345c3985b \
        --nic net-id=1080d16b-2dbf-486a-ae2d-09a334fa1d8e \
        --nic net-id=a3f547a1-937d-4a6e-9ea4-3315719e1a4b \
        --security-group default \

you can conveniently launch an instance in openstack dashboard

  • verify container status
sudo virsh -c lxc:// list
sudo virsh
virsh# connect lxc://
virsh# list
virsh# vcpuinfo id
virsh# console instance-000000xx
virsh# edit instance-000000xx

Leave a Reply

Your email address will not be published. Required fields are marked *