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