Complete docker compose setup.

This change proposes a minimal openstack deployment stood up using
docker-compose.  Included is a script to generate the necessary
environment variables for use by the containers as well as an
'openrc'.  There is also a script which demonstrates starting the
included services.

We have this working locally using patched containers and can start
instances with networking etc.  However, there are several changes
required to various containers that will need to be made to get this
working.  We are also using Steven Dake's patches to docker-compose to
allow the use of pid=host.  I propose we either merge this change or
build changes on top of this to get a functioning installation.

Co-authored-by: Ryan Hallisey <rhallise@redhat.com>

Change-Id: I5e6051054d31edf9840c3a22502d4a7963893f29
This commit is contained in:
Ian Main 2015-03-12 13:22:47 -07:00
parent 4f622797ae
commit dcb607d369
3 changed files with 216 additions and 0 deletions

25
compose/README.md Normal file
View File

@ -0,0 +1,25 @@
Docker compose
==============
These scripts and docker compose files can be used to stand up a simple
installation of openstack. Running the 'genenv.sh' script creates an
'openstack.env' suitable for running on a single host system as well as an
'openrc' to allow access to the installation.
Once you have run that you can either manually start the containers using the
'docker-compose' command or try the 'start.sh' script which tries to start them
all in a reasonable order, waiting at key points for services to become
available. Once stood up you can issue the typical openstack commands to use
the installation:
```
# source openrc
# nova network-create vmnet --fixed-range-v4=10.0.0.0/24 --bridge=br100 --multi-host=T
# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
#
# nova keypair-add mykey > mykey.pem
# chmod 600 mykey.pem
# nova boot --flavor m1.medium --key_name mykey --image puffy_clouds instance_name
# ssh -i mykey.pem cirros@<ip>
```

106
compose/genenv.sh Executable file
View File

@ -0,0 +1,106 @@
#!/bin/bash
#
# This script generates a minimal set of environment variables to allow
# the openstack containers to operate. It is creating a configuration
# suitable for an all-in-one installation of openstack.
#
# It also creates a suitable 'openrc' for use with the installed system.
MY_IP=$(ip route get $(ip route | awk '$1 == "default" {print $3}') |
awk '$4 == "src" {print $5}')
MY_DEV=$(ip route get $(ip route | awk '$1 == "default" {print $3}') |
awk '$4 == "src" {print $3}')
echo MY_IP=$MY_IP
echo MY_DEV=$MY_DEV
# Database
HOST_IP=$MY_IP
MYSQL_ROOT_PASSWORD=kolla
PASSWORD=12345
# Host
ADMIN_TENANT_NAME=admin
PUBLIC_IP=$HOST_IP
# RabbitMQ
RABBITMQ_SERVICE_HOST=$HOST_IP
RABBIT_USER=guest
RABBIT_PASSWORD=guest
# Keystone
KEYSTONE_ADMIN_TOKEN=$PASSWORD
KEYSTONE_DB_PASSWORD=kolla
KEYSTONE_ADMIN_PASSWORD=$PASSWORD
KEYSTONE_PUBLIC_SERVICE_HOST=$HOST_IP
KEYSTONE_ADMIN_SERVICE_HOST=$HOST_IP
KEYSTONE_AUTH_PROTOCOL=http
# Glance
GLANCE_DB_NAME=glance
GLANCE_DB_USER=glance
GLANCE_DB_PASSWORD=kolla
GLANCE_KEYSTONE_USER=glance
GLANCE_KEYSTONE_PASSWORD=glance
GLANCE_API_SERVICE_HOST=$HOST_IP
GLANCE_REGISTRY_SERVICE_HOST=$HOST_IP
# Nova
NOVA_DB_PASSWORD=nova
NOVA_DB_NAME=nova
NOVA_DB_USER=nova
NOVA_KEYSTONE_USER=nova
NOVA_KEYSTONE_PASSWORD=nova
NOVA_API_SERVICE_HOST=$HOST_IP
NOVA_EC2_SERVICE_HOST=$HOST_IP
NOVA_PUBLIC_INTERFACE=$MY_DEV
NOVA_FLAT_INTERFACE=$MY_DEV
CONFIG_NETWORK=True
cat > openrc <<EOF
export OS_AUTH_URL="http://${KEYSTONE_PUBLIC_SERVICE_HOST}:5000/v2.0"
export OS_USERNAME=$ADMIN_TENANT_NAME
export OS_PASSWORD=$PASSWORD
export OS_TENANT_NAME=$ADMIN_TENANT_NAME
EOF
cat > openstack.env <<EOF
ADMIN_TENANT_NAME=$ADMIN_TENANT_NAME
CONFIG_NETWORK=$CONFIG_NETWORK
DB_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
FLAT_INTERFACE=$NOVA_FLAT_INTERFACE
GLANCE_API_SERVICE_HOST=$GLANCE_API_SERVICE_HOST
GLANCE_DB_NAME=$GLANCE_DB_NAME
GLANCE_DB_PASSWORD=$GLANCE_DB_PASSWORD
GLANCE_DB_USER=$GLANCE_DB_USER
GLANCE_KEYSTONE_PASSWORD=$GLANCE_KEYSTONE_PASSWORD
GLANCE_KEYSTONE_USER=$GLANCE_KEYSTONE_USER
GLANCE_REGISTRY_SERVICE_HOST=$GLANCE_REGISTRY_SERVICE_HOST
KEYSTONE_ADMIN_PASSWORD=$KEYSTONE_ADMIN_PASSWORD
KEYSTONE_ADMIN_SERVICE_HOST=$KEYSTONE_ADMIN_SERVICE_HOST
KEYSTONE_ADMIN_SERVICE_PORT=5000
KEYSTONE_ADMIN_TOKEN=$KEYSTONE_ADMIN_TOKEN
KEYSTONE_AUTH_PROTOCOL=$KEYSTONE_AUTH_PROTOCOL
KEYSTONE_DB_PASSWORD=$KEYSTONE_DB_PASSWORD
KEYSTONE_PUBLIC_SERVICE_HOST=$KEYSTONE_PUBLIC_SERVICE_HOST
MARIADB_SERVICE_HOST=$HOST_IP
MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
NETWORK_MANAGER=nova
NOVA_API_SERVICE_HOST=$NOVA_API_SERVICE_HOST
NOVA_DB_NAME=$NOVA_DB_NAME
NOVA_DB_PASSWORD=$NOVA_DB_PASSWORD
NOVA_DB_USER=$NOVA_DB_USER
NOVA_EC2_API_SERVICE_HOST=$NOVA_EC2_SERVICE_HOST
NOVA_EC2_SERVICE_HOST=$NOVA_EC2_SERVICE_HOST
NOVA_KEYSTONE_PASSWORD=$NOVA_KEYSTONE_PASSWORD
NOVA_KEYSTONE_USER=$NOVA_KEYSTONE_USER
PUBLIC_INTERFACE=$NOVA_PUBLIC_INTERFACE
PUBLIC_IP=$HOST_IP
PUBLIC_IP=$PUBLIC_IP
RABBITMQ_PASS=$RABBIT_PASSWORD
RABBITMQ_SERVICE_HOST=$RABBITMQ_SERVICE_HOST
RABBITMQ_USER=$RABBIT_USER
RABBIT_PASSWORD=$RABBIT_PASSWORD
RABBIT_USERID=$RABBIT_USER
EOF

85
compose/start.sh Executable file
View File

@ -0,0 +1,85 @@
#!/bin/bash -x
#
# This script can be used to start a minimal set of containers that allows
# you to boot an instance. Note that it requires that you have some openstack
# clients available: keystone, glance, and nova, as well as mysql to ensure
# services are up. You will also need these in order to interact with the
# installation once started.
setenforce 0
# This should probably go into nova-networking or nova-compute containers.
modprobe ebtables
MY_IP=$(ip route get $(ip route | awk '$1 == "default" {print $3}') |
awk '$4 == "src" {print $5}')
# Source openrc for commands
source openrc
echo Starting rabbitmq and mariadb
docker-compose -f rabbitmq.yml up -d
docker-compose -f mariadb.yml up -d
until mysql -u root --password=kolla --host=$MY_IP mysql -e "show tables;"
do
echo waiting for mysql..
sleep 3
done
echo Starting keystone
docker-compose -f keystone.yml up -d
until keystone user-list
do
echo waiting for keystone..
sleep 3
done
echo Starting glance
docker-compose -f glance-api-registry.yml up -d
echo Starting nova
docker-compose -f nova-api-conductor-scheduler.yml up -d
# I think we'll need this..
#
# until mysql -u root --password=kolla --host=$MY_IP mysql -e "use nova;"
# do
# echo waiting for nova db.
# sleep 3
# done
echo "Waiting for nova-api to create keystone user.."
until keystone user-list | grep nova
do
echo waiting for keystone nova user
sleep 2
done
# This directory is shared with the host to allow qemu instance
# configs to remain accross restarts.
mkdir -p /etc/libvirt/qemu
echo Starting nova compute
docker-compose -f nova-compute-network.yml up -d
IMAGE_URL=http://download.cirros-cloud.net/0.3.3/
IMAGE=cirros-0.3.3-x86_64-disk.img
if ! [ -f "$IMAGE" ]; then
curl -o $IMAGE $IMAGE_URL/$IMAGE
fi
echo "Creating glance image.."
glance image-create --name "puffy_clouds" --is-public true --disk-format qcow2 --container-format bare --file $IMAGE
# Example usage:
#
# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
# nova network-create vmnet --fixed-range-v4=10.0.0.0/24 --bridge=br100 --multi-host=T
#
# nova keypair-add mykey > mykey.pem
# chmod 600 mykey.pem
# nova boot --flavor m1.medium --key_name mykey --image puffy_clouds newInstanceName