Feeds:
Posts
Comments

Archive for January, 2014

I will share my experience on the subject in detail. The guide will definitely work if you follow this with the versions of the software specified.

Software: 64bit server of Ubuntu 13.04.
Openstack Havana/stable branch
Docker version 0.7.6
Oracle virtualbox version 4.1.12_ubuntu

This worked for me with ubuntu running on virtualbox. The vertualbox version need not be exact. But if you need this definetely work follow the exact Ubuntu and Docker versions because I have not tested on other versions. But I believe these instructions will work with prior Ubuntu and Docker versions as well with slight changes.

I use the devstack setup to install Havana and Docker. It is difficult to maintain our own scripts with the fast growing development of Openstack with new technologies, hence the idea of following devstack scripts. My previous choice of lxc driver is changed to dokcer since I feel that lxc/libvirt driver soupport in Openstack commnunity is somewhat lagging and Docker community show promising growth. Besides Docker is based on lxc with better isolation and features. Most attracting idea of docker for me is the concept of portable containers.

In this setup all nova services run in a single virtual machine. This setup is mainly used to test my Apache Stratos PaaS environment where the Openstack/Docker is used as a IaaS layer.

Scripts which appear within this article can be downloaded from [1]
It is good habit to take virtualbox snapshots at every important step of the process. This way if something goes wrong, you can re-start from the previously saved state. I strongly recommend to follow the instructions exactly as indicated in the article. Once you achieved the article goal, you can do your own experiments beginning from various snapshots saved. Later you can delete snapshots to save disk space.

If you are too eager to get the setup running follow the Quick Steps below. Quick Steps guide will assume you are familiar with virtualbox environment and Openstack devstack setup. If you run into problems or need detailed steps I recommend you follow the whole blog entry as a tutorial. Also for quick steps download the scripts and other stuff from [1].

Quick Instructions

Download:

Download interfaces, hypervisor-docker, install_docker0.sh, install_docker1.sh, localrc and driver.py files from [1].

Setup Virtualbox:

Install Ubuntu 13.04 64 bit version in virtualbox with at least 40G dyanmically growing hard disk. Add hostonly interface eth1 with gateway 192.168.92.1. Add hostonly interface eth2 with gateway 192.168.57.1. Log in and create a user/password called wso2/g. Replace /etc/network/interfaces file with downloaded interface file. Reboot vm, open a terminal and ssh into instance

ssh wso2@192.168.57.30

sudo apt-get update

sudo apt-get install linux-image-3.8.0-26-generic

Reboot

Setup Docker:

sudo apt-get install git
git clone https://github.com/openstack-dev/devstack.git
cd devstack
git checkout stable/havana

Replace devstack/lib/nova_plugins/hypervisor-docker with the downloaded hypervisor-docker file.
Copy install_docker0.sh and install_docker1.sh into /devstack/tools/docker folder.
cd devstack
./tools/docker/install_docker0.sh
sudo usermod -a -G docker wso2
sudo chown wso2:docker /var/run/docker.sock
./tools/docker/install_docker1.sh
sudo service docker restart
cd files
curl -OR http://get.docker.io/images/openstack/docker-ut.tar.gz
docker import - docker-busybox < ./docker-ut.tar.gz
If permission denied error occur execute the following command again.
sudo chown wso2:docker /var/run/docker.sock
url -OR http://get.docker.io/images/openstack/docker-registry.tar.gz
ocker import - docker-registry < ./docker-registry.tar.gz
Set ipv4 forwarding in /etc/sysctl.conf
net.ipv4.ip_forward = 1
sudo apt-get install lxc wget bsdtar curl
sudo apt-get install linux-image-extra-3.8.0-26-generic
sudo modprobe aufs

Add following three lines to /etc/rc.local
chown wso2:docker /var/run/docker.sock
modprobe aufs
sudo killall dnsmasq

Setup Openstack:

Copy localrc file to devstack folder
cd devstack
./stack.sh
After stack.sh finished successfully execute docker images to see docker registry is still there. If there are no images do following again
cd devstack/files
docker import - docker-registry < ./docker-registry.tar.gz
Replace /opt/stack/nova/nova/virt/docker/driver.py with downlaoded driver.py
Reboot vm.
cd devstack
./stack.sh
Test:
Log into Horizon, add icmp and ssh rules to security group and create an instance of busybox image.

Detailed  Instructions

First install Ubuntu 13.04 in a Virtualbox VM. Add a host-only network adaptor to it. In the ipv4 Address field put 192.168.92.1 and ipv4 Network Mask field put 255.255.255.0 . Add another host-only network adaptor. In the ipv4 Address field put 192.168.57.1 and ipv4 Network Mask field put 255.255.255.0 . Make sure to give at least 40G dynamically growing hard disk. Now boot up the VM and follow the steps below. Connect using the terminal ui provided by virtualbox and create a user/password called wso2/g.

Change /etc/network/interfaces as following

auto eth0
iface eth0 inet dhcp


auto eth1
iface eth1 inet static
address 192.168.92.30
network 192.168.92.0
netmask 255.255.255.0
broadcast 192.168.92.255


auto eth2
iface eth2 inet manual
up ifconfig eth2 192.168.57.30 up

Now reboot and you can connect to the VM from a terminal using username wso2 and password g.

ssh wso2@192.168.57.30
Now from within this terminal exeute

sudo apt-get update

Now in order for Openstack/Docker to work correctly we need a linux kernel upgrade for ubuntu

sudo apt-get install linux-image-3.8.0-26-generic

Now restart the VM node.

sudo apt-get install git

git clone https://github.com/openstack-dev/devstack.git

cd devstack

git checkout stable/havana

Now we need to apply the following patch for devstack scripts

Apply patch

The first one is in file “devstack/tools/docker/install_docker.sh”, line 41:
install_package --force-yes lxc-docker=${DOCKER_PACKAGE_VERSION} socat
should be:
install_package --force-yes lxc-docker-${DOCKER_PACKAGE_VERSION} socat

The second one is in file “devstack/lib/nova_plugins/hypervisor-docker”, line 75:
if ! is_package_installed lxc-docker; then
should be:
if ! is_package_installed lxc-docker-${DOCKER_PACKAGE_VERSION}; then

Also add the following line in devstack/lib/nova_plugins/hypervisor-docker under the entry called # Defaults

DOCKER_PACKAGE_VERSION=0.7.6

Now we are supposed to execute ./tools/docker/install_docker.sh. But don’t do it. In my case I got permission error for /var/run/docker.sock and a curl download fail for docker registry image when executed it. So I solved those two problems by following steps.

Break the installer script into two called install_docker0.sh and install_docker1.sh.

My install_docker0.sh file can be downloaded from [1]

My install_docke1.sh can be downloaded from[1]

Now run the first script
./tools/docker/install_docker0.sh

Then add wso2 user to docker group. Here username wso2 is the name you have given for your ubuntu account user.
sudo usermod -a -G docker wso2
Then change permission of the /var/run/docker.sock

sudo chown wso2:docker /var/run/docker.sock
Important:Each time you restart the virbualbox VM make sure that above permission for /var/run/docker.sock set correctly. If it is changed execute the above command and change the permission before doing anything.

Now run the second script
./tools/docker/install_docker1.sh
and
sudo service docker restart

cd files
curl -OR http://get.docker.io/images/openstack/docker-ut.tar.gz
docker import - docker-busybox < ./docker-ut.tar.gz
If permission denied error occur execute the following command again.
sudo chown wso2:docker /var/run/docker.sock
Now
curl -OR http://get.docker.io/images/openstack/docker-registry.tar.gz (Take about 20 mins in 120k per second connection)
If file transfer failed continue with
curl -C - -o docker-registry.tar.gz 'http://get.docker.io/images/openstack/docker-registry.tar.gz'
Now import
docker import - docker-registry < ./docker-registry.tar.gz
 

So by now your Docker installation should be a success. Now we need to run stack.sh script to setup Openstack. But before that let’s do the following.
Set ipv4 forwarding in /etc/sysctl.conf
net.ipv4.ip_forward = 1
To setup aufs file system which is necessary for docker driver
sudo apt-get install lxc wget bsdtar curl
sudo apt-get install linux-image-extra-3.8.0-26-generic

sudo modprobe aufs

Add following three lines to /etc/rc.local
chown wso2:docker /var/run/docker.sock
modprobe aufs
sudo killall dnsmasq

Now create a file called localrc in devstack folder and add the following content

FLOATING_RANGE=192.168.92.0/27
FIXED_RANGE=10.11.12.0/24
FIXED_NETWORK_SIZE=256
FLAT_INTERFACE=eth1
ADMIN_PASSWORD=g
MYSQL_PASSWORD=g
RABBIT_PASSWORD=g
SERVICE_PASSWORD=g
SERVICE_TOKEN=g
SCHEDULER=nova.scheduler.filter_scheduler.FilterScheduler
VIRT_DRIVER=docker
SCREEN_LOGDIR=$DEST/logs/screen

Now execute stack.sh

./stack.sh
(Take about 1.5hours in 120k per secon connection)

After stack.sh finished successfully execute docker images to see our docker registry is still there(I remember I once lost it by this time). If there are no images
cd devstack/files
docker import - docker-registry < ./docker-registry.tar.gz

Now you need to patch /opt/stack/nova/nova/virt/docker/driver.py line 317
replace
destroy_disks=True):
with
destroy_disks=True, context=None):
Now restart node.

Again
cd devstack
stack.sh

If you have followed the steps correctly you should have a working state of Openstack installation with Docker driver. Log into horizon UI(http://192.168.57.30) using admin or demo user. Paasword for those users is ‘g‘(as we set in our devstack/localrc file above) and create instances from docker-busybox image that is uploaded in the default installation.
Don’t forget to add icmp and ssh rules for the security group you use(by default this is default group). Take a snapshot of this working state before you do any further playing with your setup.

If you restart the node
cd devstack
rejoin-stack.sh
To run the nova services. Or if you need a clean Openstack environment after restarting the node instead of running rejoin-stack.sh, run stack.sh. This time it won’t take long time as the first time, only few seconds.

Nova service logs are in /opt/stack/logs/screen folder.

If you run rejoin-stack.sh you can see each nova service log in the rejoin screen. To see each service log ctrl+A and press " then select the service log you need by moving up|down arrows and then click. You can scroll up and down the rejoin screen by ctrl+A and press Esc and then use up|down or pgup|pgdown keys to scroll.

Note: for some reason eth1(flat interface) does not show the ip when rejoin-stack.sh is run. But that does not prevent connecting to the virtualbox vm. But sometimes  problem occur and thats why you add second interface eth2.

My next blog Docker Driver for Openstack Havana will be on playing around this setup like creating new customized images and secure access(ssh) the containers. I’ll also deal with a bug fix on accessing metadata serivces.

[1]https://www.dropbox.com/sh/dmmey60kvdihc31/3sbBkX7ns3

Advertisements

Read Full Post »