Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 1 | Configure Load-Balancer in Kilo |
| 2 | ================================= |
| 3 | |
| 4 | The Kilo release of OpenStack will support Version 2 of the neutron load balancer. Until now, using OpenStack `LBaaS V2 <http://docs.openstack.org/api/openstack-network/2.0/content/lbaas_ext.html>`_ has required a good understanding of neutron and LBaaS architecture and several manual steps. |
| 5 | |
| 6 | |
| 7 | Phase 1: Create DevStack + 2 nova instances |
| 8 | -------------------------------------------- |
| 9 | |
| 10 | First, set up a vm of your choice with at least 8 GB RAM and 16 GB disk space, make sure it is updated. Install git and any other developer tools you find useful. |
| 11 | |
| 12 | Install devstack |
| 13 | |
| 14 | :: |
| 15 | |
| 16 | git clone https://git.openstack.org/openstack-dev/devstack |
| 17 | cd devstack |
| 18 | |
| 19 | |
| 20 | Edit your `local.conf` to look like |
| 21 | |
| 22 | :: |
| 23 | |
| 24 | [[local|localrc]] |
| 25 | # Load the external LBaaS plugin. |
| 26 | enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas |
| 27 | |
| 28 | # ===== BEGIN localrc ===== |
| 29 | DATABASE_PASSWORD=password |
| 30 | ADMIN_PASSWORD=password |
| 31 | SERVICE_PASSWORD=password |
| 32 | SERVICE_TOKEN=password |
| 33 | RABBIT_PASSWORD=password |
| 34 | # Enable Logging |
| 35 | LOGFILE=$DEST/logs/stack.sh.log |
| 36 | VERBOSE=True |
| 37 | LOG_COLOR=True |
| 38 | SCREEN_LOGDIR=$DEST/logs |
| 39 | # Pre-requisite |
| 40 | ENABLED_SERVICES=rabbit,mysql,key |
| 41 | # Horizon |
| 42 | ENABLED_SERVICES+=,horizon |
| 43 | # Nova |
| 44 | ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch |
| 45 | IMAGE_URLS+=",https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img" |
| 46 | # Glance |
| 47 | ENABLED_SERVICES+=,g-api,g-reg |
| 48 | # Neutron |
| 49 | ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta |
| 50 | # Enable LBaaS V2 |
| 51 | ENABLED_SERVICES+=,q-lbaasv2 |
| 52 | # Cinder |
| 53 | ENABLED_SERVICES+=,c-api,c-vol,c-sch |
| 54 | # Tempest |
| 55 | ENABLED_SERVICES+=,tempest |
| 56 | # ===== END localrc ===== |
| 57 | |
| 58 | Run stack.sh and do some sanity checks |
| 59 | |
| 60 | :: |
| 61 | |
| 62 | ./stack.sh |
| 63 | . ./openrc |
| 64 | |
| 65 | neutron net-list # should show public and private networks |
| 66 | |
| 67 | Create two nova instances that we can use as test http servers: |
| 68 | |
| 69 | :: |
| 70 | |
| 71 | #create nova instances on private network |
| 72 | nova boot --image $(nova image-list | awk '/ cirros-0.3.0-x86_64-disk / {print $2}') --flavor 1 --nic net-id=$(neutron net-list | awk '/ private / {print $2}') node1 |
| 73 | nova boot --image $(nova image-list | awk '/ cirros-0.3.0-x86_64-disk / {print $2}') --flavor 1 --nic net-id=$(neutron net-list | awk '/ private / {print $2}') node2 |
| 74 | nova list # should show the nova instances just created |
| 75 | |
| 76 | #add secgroup rule to allow ssh etc.. |
| 77 | neutron security-group-rule-create default --protocol icmp |
| 78 | neutron security-group-rule-create default --protocol tcp --port-range-min 22 --port-range-max 22 |
| 79 | neutron security-group-rule-create default --protocol tcp --port-range-min 80 --port-range-max 80 |
| 80 | |
| 81 | Set up a simple web server on each of these instances. ssh into each instance (username 'cirros', password 'cubswin:)') and run |
| 82 | |
| 83 | :: |
| 84 | |
| 85 | MYIP=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}') |
| 86 | while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $MYIP" | sudo nc -l -p 80 ; done& |
| 87 | |
| 88 | Phase 2: Create your load balancers |
| 89 | ------------------------------------ |
| 90 | |
| 91 | :: |
| 92 | |
| 93 | neutron lbaas-loadbalancer-create --name lb1 private-subnet |
| 94 | neutron lbaas-listener-create --loadbalancer lb1 --protocol HTTP --protocol-port 80 --name listener1 |
| 95 | neutron lbaas-pool-create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1 |
| 96 | neutron lbaas-member-create --subnet private-subnet --address 10.0.0.3 --protocol-port 80 pool1 |
| 97 | neutron lbaas-member-create --subnet private-subnet --address 10.0.0.5 --protocol-port 80 pool1 |
| 98 | |
| 99 | Please note here that the "10.0.0.3" and "10.0.0.5" in the above commands are the IPs of the nodes (in my test run-thru, they were actually 10.2 and 10.4), and the address of the created LB will be reported as "vip_address" from the lbaas-loadbalancer-create, and a quick test of that LB is "curl that-lb-ip", which should alternate between showing the IPs of the two nodes. |