This post discusses a way to setup minimal DevStack (OpenStack development environment from git
sources) with Neutron networking, in a virtual machine.
(a) Setup minimal DevStack environment in a VM
Prepare VM, take a snapshot
Assuming you have a Linux (Fedora 21 or above or any of Debian variants) virtual machine setup (with at-least 8GB memory and 40GB of disk space), take a quick snapshot. The below creates a QCOW2 internal snapshot (that means, your disk image should be a QCOW2 image), you can invoke it live or offline:
$ virsh snapshot-create-as devstack-vm cleanslate
So that if something goes wrong, you can revert to this clean state, by simple doing:
$ virsh snapshot-revert devstack-vm cleanslate
Setup DevStack
There’s plenty of configuration variants to set up DevStack. The upstream documentation has its own recommendation of minimal configuration. The below configuration is of much smaller foot-print, which configures only: Nova (Compute, Scheduler, API and Conductor services), Keystone Neutron and Glance (Image service) services.
$ mkdir -p $HOME/sources/cloud $ git clone https://git.openstack.org/openstack-dev/devstack $ chmod go+rx $HOME $ cat << EOF > local.conf [[local|localrc]] DEST=$HOME/sources/cloud DATA_DIR=$DEST/data SERVICE_DIR=$DEST/status SCREEN_LOGDIR=$DATA_DIR/logs/ LOGFILE=/$DATA_DIR/logs/devstacklog.txt VERBOSE=True USE_SCREEN=True LOG_COLOR=True RABBIT_PASSWORD=secret MYSQL_PASSWORD=secret SERVICE_TOKEN=secret SERVICE_PASSWORD=secret ADMIN_PASSWORD=secret ENABLED_SERVICES=g-api,g-reg,key,n-api,n-cpu,n-sch,n-cond,mysql,rabbit,dstat,quantum,q-svc,q-agt,q-dhcp,q-l3,q-meta SERVICE_HOST=127.0.0.1 NETWORK_GATEWAY=10.1.0.1 FIXED_RANGE=10.1.0.0/24 FIXED_NETWORK_SIZE=256 FORCE_CONFIG_DRIVE=always VIRT_DRIVER=libvirt # To use nested KVM, un-comment the below line # LIBVIRT_TYPE=kvm IMAGE_URLS="http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img" # If you have `dnf` package manager, use it to improve speedups in DevStack build/tear down export YUM=dnf
NOTE: If you’re using KVM-based virtualization under the hood, refer this upstream documentation on setting it up with DevStack, so that the VMs in your OpenStack cloud (i.e. Nova instances) can run, relatively, faster than with plain QEMU emulation. So, if you have the relevant hardware, you might want setup that before proceeding further.
Invoke the install script:
$ ./stack.sh
[27MAR2015 Update]: Don’t forget to systemctl enable
the below services so they start on reboot — this allows you to successfully start all OpenStack services when you reboot your DevStack VM:
$ systemctl enable openvswitch mariadb rabbitmq-server
(b) Configure Neutron networking
Once DevStack installation completes successfully, let’s setup Neutron networking.
Set Neutron router and add security group rules
(1) Source the user tenant (‘demo’ user) credentials:
$ . openrc demo
(2) Enumerate Neutron security group rules:
$ neutron security-group-list
(3) Create a couple of environment variables, for convenience, capturing the IDs of Neutron public, private networks and router:
$ PUB_NET=$(neutron net-list | grep public | awk '{print $2;}') $ PRIV_NET=$(neutron net-list | grep private | awk '{print $2;}') $ ROUTER_ID=$(neutron router-list | grep router1 | awk '{print $2;}')
(4) Set the Neutron gateway for router:
$ neutron router-gateway-set $ROUTER_ID $PUB_NET
(5) Add security group rules to enable ping
and ssh
:
$ neutron security-group-rule-create --protocol icmp \ --direction ingress --remote-ip-prefix 0.0.0.0/0 default $ neutron security-group-rule-create --protocol tcp \ --port-range-min 22 --port-range-max 22 --direction ingress default
Boot a Nova instance
Source the ‘demo’ user’s Keystone credentials, add a Nova key pair, and boot an ‘m1.small’ flavored CirrOS instance:
$ . openrc demo $ nova keypair-add oskey1 > oskey1.priv $ chmod 600 oskey1.priv $ nova boot --image cirros-0.3.3-x86_64-disk \ --nic net-id=$PRIV_NET --flavor m1.small \ --key_name oskey1 cirrvm1 --security_groups default
Create a floating IP and assign it to the Nova instance
The below sequence of commands enumerate the Nova instance, finds the Neutron port ID for a specific instance. Then, creates a floating IP, associates it to the Nova instance. Then, again, enumerates the Nova instances, so you can notice both floating and fixed IPs for it:
$ nova list $ neutron port-list --device-id $NOVA-INSTANCE-UUID $ neutron floatingip-create public $ neutron floatingip-associate $FLOATING-IP-UUID $PORT-ID-OF-NOVA-INSTANCE $ nova list
A new tenant network creation can be trivially done with a script like this.
Optionally, test the networking setup by trying to ping
or ssh
into the CirrOS Nova instance.
Given the procedural nature of the above, all of this can be trivially scripted to suit your needs — in fact, upstream OpenStack Infrastructure does use such automated DevStack environments to gate (as part of CI) every change that is submitted to any of the various OpenStack projects.
Finally, to find out how minimal it really is, one way to test is to check the memory footprint inside the DevStack VM, using the ps_mem
tool and compare that with a Different DevStack environment with more OpenStack services enabled. Edit: A quick memory profile in a Minimal DevStack environment here — 1.3GB of memory without any Nova instances running (but, with OpenStack services running).