Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 1 | Devstack with Octavia Load Balancing |
| 2 | ==================================== |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 3 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 4 | Starting with the OpenStack Pike release, Octavia is now a standalone service |
| 5 | providing load balancing services for OpenStack. |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 6 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 7 | This guide will show you how to create a devstack with `Octavia API`_ enabled. |
| 8 | |
| 9 | .. _Octavia API: https://developer.openstack.org/api-ref/load-balancer/v2/index.html |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 10 | |
| 11 | Phase 1: Create DevStack + 2 nova instances |
| 12 | -------------------------------------------- |
| 13 | |
Richard Theis | 7e55068 | 2015-10-13 07:51:05 -0500 | [diff] [blame] | 14 | First, set up a vm of your choice with at least 8 GB RAM and 16 GB disk space, |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 15 | make sure it is updated. Install git and any other developer tools you find |
| 16 | useful. |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 17 | |
| 18 | Install devstack |
| 19 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 20 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 21 | |
| 22 | git clone https://git.openstack.org/openstack-dev/devstack |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 23 | cd devstack/tools |
| 24 | sudo ./create-stack-user.sh |
| 25 | cd ../.. |
| 26 | sudo mv devstack /opt/stack |
| 27 | sudo chown -R stack.stack /opt/stack/devstack |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 28 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 29 | This will clone the current devstack code locally, then setup the "stack" |
| 30 | account that devstack services will run under. Finally, it will move devstack |
| 31 | into its default location in /opt/stack/devstack. |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 32 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 33 | Edit your ``/opt/stack/devstack/local.conf`` to look like |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 34 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 35 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 36 | |
| 37 | [[local|localrc]] |
Richard Theis | 7e55068 | 2015-10-13 07:51:05 -0500 | [diff] [blame] | 38 | enable_plugin octavia https://git.openstack.org/openstack/octavia |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 39 | # If you are enabling horizon, include the octavia dashboard |
| 40 | # enable_plugin octavia-dashboard https://git.openstack.org/openstack/octavia-dashboard.git |
| 41 | # If you are enabling barbican for TLS offload in Octavia, include it here. |
| 42 | # enable_plugin barbican https://github.com/openstack/barbican.git |
| 43 | |
| 44 | # If you have python3 available: |
| 45 | # USE_PYTHON3=True |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 46 | |
| 47 | # ===== BEGIN localrc ===== |
| 48 | DATABASE_PASSWORD=password |
| 49 | ADMIN_PASSWORD=password |
| 50 | SERVICE_PASSWORD=password |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 51 | SERVICE_TOKEN=password |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 52 | RABBIT_PASSWORD=password |
| 53 | # Enable Logging |
| 54 | LOGFILE=$DEST/logs/stack.sh.log |
| 55 | VERBOSE=True |
| 56 | LOG_COLOR=True |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 57 | # Pre-requisite |
| 58 | ENABLED_SERVICES=rabbit,mysql,key |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 59 | # Horizon - enable for the OpenStack web GUI |
| 60 | # ENABLED_SERVICES+=,horizon |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 61 | # Nova |
Matt Riedemann | 62e27d3 | 2019-04-23 13:44:37 -0400 | [diff] [blame^] | 62 | ENABLED_SERVICES+=,n-api,n-crt,n-cpu,n-cond,n-sch,n-api-meta,n-sproxy |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 63 | ENABLED_SERVICES+=,placement-api,placement-client |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 64 | # Glance |
| 65 | ENABLED_SERVICES+=,g-api,g-reg |
| 66 | # Neutron |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 67 | ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron |
Richard Theis | 7e55068 | 2015-10-13 07:51:05 -0500 | [diff] [blame] | 68 | ENABLED_SERVICES+=,octavia,o-cw,o-hk,o-hm,o-api |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 69 | # Cinder |
| 70 | ENABLED_SERVICES+=,c-api,c-vol,c-sch |
| 71 | # Tempest |
| 72 | ENABLED_SERVICES+=,tempest |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 73 | # Barbican - Optionally used for TLS offload in Octavia |
| 74 | # ENABLED_SERVICES+=,barbican |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 75 | # ===== END localrc ===== |
| 76 | |
| 77 | Run stack.sh and do some sanity checks |
| 78 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 79 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 80 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 81 | sudo su - stack |
| 82 | cd /opt/stack/devstack |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 83 | ./stack.sh |
| 84 | . ./openrc |
| 85 | |
Armando Migliaccio | 4f11ff3 | 2016-10-27 06:15:23 -0700 | [diff] [blame] | 86 | openstack network list # should show public and private networks |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 87 | |
| 88 | Create two nova instances that we can use as test http servers: |
| 89 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 90 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 91 | |
| 92 | #create nova instances on private network |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 93 | openstack server create --image $(openstack image list | awk '/ cirros-.*-x86_64-.* / {print $2}') --flavor 1 --nic net-id=$(openstack network list | awk '/ private / {print $2}') node1 |
| 94 | openstack server creeate --image $(openstack image list | awk '/ cirros-.*-x86_64-.* / {print $2}') --flavor 1 --nic net-id=$(openstack network list | awk '/ private / {print $2}') node2 |
| 95 | openstack server list # should show the nova instances just created |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 96 | |
Richard Theis | 7e55068 | 2015-10-13 07:51:05 -0500 | [diff] [blame] | 97 | #add secgroup rules to allow ssh etc.. |
Armando Migliaccio | 4f11ff3 | 2016-10-27 06:15:23 -0700 | [diff] [blame] | 98 | openstack security group rule create default --protocol icmp |
| 99 | openstack security group rule create default --protocol tcp --dst-port 22:22 |
| 100 | openstack security group rule create default --protocol tcp --dst-port 80:80 |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 101 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 102 | Set up a simple web server on each of these instances. ssh into each instance (username 'cirros', password 'cubswin:)' or 'gocubsgo') and run |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 103 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 104 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 105 | |
| 106 | MYIP=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}') |
| 107 | while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $MYIP" | sudo nc -l -p 80 ; done& |
| 108 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 109 | Phase 2: Create your load balancer |
| 110 | ---------------------------------- |
| 111 | |
| 112 | Make sure you have the 'openstack loadbalancer' commands: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 113 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 114 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 115 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 116 | pip install python-octaviaclient |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 117 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 118 | Create your load balancer: |
| 119 | |
| 120 | :: |
| 121 | |
| 122 | openstack loadbalancer create --name lb1 --vip-subnet-id private-subnet |
| 123 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 124 | openstack loadbalancer listener create --protocol HTTP --protocol-port 80 --name listener1 lb1 |
| 125 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 126 | openstack loadbalancer pool create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1 |
| 127 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 128 | openstack loadbalancer healthmonitor create --delay 5 --timeout 2 --max-retries 1 --type HTTP pool1 |
| 129 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 130 | openstack loadbalancer member create --subnet-id private-subnet --address <web server 1 address> --protocol-port 80 pool1 |
| 131 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 132 | openstack loadbalancer member create --subnet-id private-subnet --address <web server 2 address> --protocol-port 80 pool1 |
| 133 | |
| 134 | Please note: The <web server # address> fields are the IP addresses of the nova |
| 135 | servers created in Phase 1. |
| 136 | Also note, using the API directly you can do all of the above commands in one |
| 137 | API call. |
| 138 | |
| 139 | Phase 3: Test your load balancer |
| 140 | -------------------------------- |
| 141 | |
| 142 | :: |
| 143 | |
| 144 | openstack loadbalancer show lb1 # Note the vip_address |
| 145 | curl http://<vip_address> |
| 146 | curl http://<vip_address> |
| 147 | |
| 148 | This should show the "Welcome to <IP>" message from each member server. |