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 | |
Andreas Jaeger | 0fc6b2c | 2019-07-30 17:52:55 +0200 | [diff] [blame] | 9 | .. _Octavia API: https://docs.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 | |
Matt Riedemann | 9b6d2f2 | 2019-06-18 10:43:16 -0400 | [diff] [blame] | 22 | git clone https://opendev.org/openstack/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]] |
Matt Riedemann | 9b6d2f2 | 2019-06-18 10:43:16 -0400 | [diff] [blame] | 38 | enable_plugin octavia https://opendev.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 |
Matt Riedemann | 9b6d2f2 | 2019-06-18 10:43:16 -0400 | [diff] [blame] | 40 | # enable_plugin octavia-dashboard https://opendev.org/openstack/octavia-dashboard.git |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 41 | # If you are enabling barbican for TLS offload in Octavia, include it here. |
Andreas Jaeger | 8dd89e5 | 2019-08-11 16:00:12 +0200 | [diff] [blame] | 42 | # enable_plugin barbican https://opendev.org/openstack/barbican |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 43 | |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 44 | # ===== BEGIN localrc ===== |
| 45 | DATABASE_PASSWORD=password |
| 46 | ADMIN_PASSWORD=password |
| 47 | SERVICE_PASSWORD=password |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 48 | SERVICE_TOKEN=password |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 49 | RABBIT_PASSWORD=password |
| 50 | # Enable Logging |
| 51 | LOGFILE=$DEST/logs/stack.sh.log |
| 52 | VERBOSE=True |
| 53 | LOG_COLOR=True |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 54 | # Pre-requisite |
| 55 | ENABLED_SERVICES=rabbit,mysql,key |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 56 | # Horizon - enable for the OpenStack web GUI |
| 57 | # ENABLED_SERVICES+=,horizon |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 58 | # Nova |
Matt Riedemann | 62e27d3 | 2019-04-23 13:44:37 -0400 | [diff] [blame] | 59 | 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] | 60 | ENABLED_SERVICES+=,placement-api,placement-client |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 61 | # Glance |
Takashi Kajinami | c3db92b | 2020-06-04 23:57:18 +0900 | [diff] [blame] | 62 | ENABLED_SERVICES+=,g-api |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 63 | # Neutron |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 64 | 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] | 65 | ENABLED_SERVICES+=,octavia,o-cw,o-hk,o-hm,o-api |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 66 | # Cinder |
| 67 | ENABLED_SERVICES+=,c-api,c-vol,c-sch |
| 68 | # Tempest |
| 69 | ENABLED_SERVICES+=,tempest |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 70 | # Barbican - Optionally used for TLS offload in Octavia |
| 71 | # ENABLED_SERVICES+=,barbican |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 72 | # ===== END localrc ===== |
| 73 | |
| 74 | Run stack.sh and do some sanity checks |
| 75 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 76 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 77 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 78 | sudo su - stack |
| 79 | cd /opt/stack/devstack |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 80 | ./stack.sh |
| 81 | . ./openrc |
| 82 | |
Armando Migliaccio | 4f11ff3 | 2016-10-27 06:15:23 -0700 | [diff] [blame] | 83 | openstack network list # should show public and private networks |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 84 | |
| 85 | Create two nova instances that we can use as test http servers: |
| 86 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 87 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 88 | |
| 89 | #create nova instances on private network |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 90 | 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 |
Lucas Xu | f745a0a | 2019-05-30 20:49:29 +0000 | [diff] [blame] | 91 | 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}') node2 |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 92 | openstack server list # should show the nova instances just created |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 93 | |
Richard Theis | 7e55068 | 2015-10-13 07:51:05 -0500 | [diff] [blame] | 94 | #add secgroup rules to allow ssh etc.. |
Armando Migliaccio | 4f11ff3 | 2016-10-27 06:15:23 -0700 | [diff] [blame] | 95 | openstack security group rule create default --protocol icmp |
| 96 | openstack security group rule create default --protocol tcp --dst-port 22:22 |
| 97 | openstack security group rule create default --protocol tcp --dst-port 80:80 |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 98 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 99 | 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] | 100 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 101 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 102 | |
| 103 | MYIP=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}') |
| 104 | while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $MYIP" | sudo nc -l -p 80 ; done& |
| 105 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 106 | Phase 2: Create your load balancer |
| 107 | ---------------------------------- |
| 108 | |
| 109 | Make sure you have the 'openstack loadbalancer' commands: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 110 | |
David Rabel | c77c949 | 2018-04-05 20:56:22 +0200 | [diff] [blame] | 111 | :: |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 112 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 113 | pip install python-octaviaclient |
Aishwarya Thangappa | 7c57306 | 2015-02-18 01:51:13 -0800 | [diff] [blame] | 114 | |
Michael Johnson | 8b9864d | 2019-01-24 10:49:35 -0800 | [diff] [blame] | 115 | Create your load balancer: |
| 116 | |
| 117 | :: |
| 118 | |
| 119 | openstack loadbalancer create --name lb1 --vip-subnet-id private-subnet |
| 120 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 121 | openstack loadbalancer listener create --protocol HTTP --protocol-port 80 --name listener1 lb1 |
| 122 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 123 | openstack loadbalancer pool create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1 |
| 124 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 125 | openstack loadbalancer healthmonitor create --delay 5 --timeout 2 --max-retries 1 --type HTTP pool1 |
| 126 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 127 | openstack loadbalancer member create --subnet-id private-subnet --address <web server 1 address> --protocol-port 80 pool1 |
| 128 | openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE. |
| 129 | openstack loadbalancer member create --subnet-id private-subnet --address <web server 2 address> --protocol-port 80 pool1 |
| 130 | |
| 131 | Please note: The <web server # address> fields are the IP addresses of the nova |
| 132 | servers created in Phase 1. |
| 133 | Also note, using the API directly you can do all of the above commands in one |
| 134 | API call. |
| 135 | |
| 136 | Phase 3: Test your load balancer |
| 137 | -------------------------------- |
| 138 | |
| 139 | :: |
| 140 | |
| 141 | openstack loadbalancer show lb1 # Note the vip_address |
| 142 | curl http://<vip_address> |
| 143 | curl http://<vip_address> |
| 144 | |
| 145 | This should show the "Welcome to <IP>" message from each member server. |