blob: db138ae2c59eed1e4c13469d2fc921eb5864c2c1 [file] [log] [blame]
Michael Johnson8b9864d2019-01-24 10:49:35 -08001Devstack with Octavia Load Balancing
2====================================
Aishwarya Thangappa7c573062015-02-18 01:51:13 -08003
Michael Johnson8b9864d2019-01-24 10:49:35 -08004Starting with the OpenStack Pike release, Octavia is now a standalone service
5providing load balancing services for OpenStack.
Aishwarya Thangappa7c573062015-02-18 01:51:13 -08006
Michael Johnson8b9864d2019-01-24 10:49:35 -08007This 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 Thangappa7c573062015-02-18 01:51:13 -080010
11Phase 1: Create DevStack + 2 nova instances
12--------------------------------------------
13
Richard Theis7e550682015-10-13 07:51:05 -050014First, set up a vm of your choice with at least 8 GB RAM and 16 GB disk space,
Michael Johnson8b9864d2019-01-24 10:49:35 -080015make sure it is updated. Install git and any other developer tools you find
16useful.
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080017
18Install devstack
19
David Rabelc77c9492018-04-05 20:56:22 +020020::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080021
22 git clone https://git.openstack.org/openstack-dev/devstack
Michael Johnson8b9864d2019-01-24 10:49:35 -080023 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 Thangappa7c573062015-02-18 01:51:13 -080028
Michael Johnson8b9864d2019-01-24 10:49:35 -080029This will clone the current devstack code locally, then setup the "stack"
30account that devstack services will run under. Finally, it will move devstack
31into its default location in /opt/stack/devstack.
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080032
Michael Johnson8b9864d2019-01-24 10:49:35 -080033Edit your ``/opt/stack/devstack/local.conf`` to look like
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080034
David Rabelc77c9492018-04-05 20:56:22 +020035::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080036
37 [[local|localrc]]
Richard Theis7e550682015-10-13 07:51:05 -050038 enable_plugin octavia https://git.openstack.org/openstack/octavia
Michael Johnson8b9864d2019-01-24 10:49:35 -080039 # 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 Thangappa7c573062015-02-18 01:51:13 -080046
47 # ===== BEGIN localrc =====
48 DATABASE_PASSWORD=password
49 ADMIN_PASSWORD=password
50 SERVICE_PASSWORD=password
Michael Johnson8b9864d2019-01-24 10:49:35 -080051 SERVICE_TOKEN=password
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080052 RABBIT_PASSWORD=password
53 # Enable Logging
54 LOGFILE=$DEST/logs/stack.sh.log
55 VERBOSE=True
56 LOG_COLOR=True
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080057 # Pre-requisite
58 ENABLED_SERVICES=rabbit,mysql,key
Michael Johnson8b9864d2019-01-24 10:49:35 -080059 # Horizon - enable for the OpenStack web GUI
60 # ENABLED_SERVICES+=,horizon
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080061 # Nova
Matt Riedemann62e27d32019-04-23 13:44:37 -040062 ENABLED_SERVICES+=,n-api,n-crt,n-cpu,n-cond,n-sch,n-api-meta,n-sproxy
Michael Johnson8b9864d2019-01-24 10:49:35 -080063 ENABLED_SERVICES+=,placement-api,placement-client
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080064 # Glance
65 ENABLED_SERVICES+=,g-api,g-reg
66 # Neutron
Michael Johnson8b9864d2019-01-24 10:49:35 -080067 ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron
Richard Theis7e550682015-10-13 07:51:05 -050068 ENABLED_SERVICES+=,octavia,o-cw,o-hk,o-hm,o-api
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080069 # Cinder
70 ENABLED_SERVICES+=,c-api,c-vol,c-sch
71 # Tempest
72 ENABLED_SERVICES+=,tempest
Michael Johnson8b9864d2019-01-24 10:49:35 -080073 # Barbican - Optionally used for TLS offload in Octavia
74 # ENABLED_SERVICES+=,barbican
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080075 # ===== END localrc =====
76
77Run stack.sh and do some sanity checks
78
David Rabelc77c9492018-04-05 20:56:22 +020079::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080080
Michael Johnson8b9864d2019-01-24 10:49:35 -080081 sudo su - stack
82 cd /opt/stack/devstack
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080083 ./stack.sh
84 . ./openrc
85
Armando Migliaccio4f11ff32016-10-27 06:15:23 -070086 openstack network list # should show public and private networks
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080087
88Create two nova instances that we can use as test http servers:
89
David Rabelc77c9492018-04-05 20:56:22 +020090::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080091
92 #create nova instances on private network
Michael Johnson8b9864d2019-01-24 10:49:35 -080093 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 Xuf745a0a2019-05-30 20:49:29 +000094 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 Johnson8b9864d2019-01-24 10:49:35 -080095 openstack server list # should show the nova instances just created
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080096
Richard Theis7e550682015-10-13 07:51:05 -050097 #add secgroup rules to allow ssh etc..
Armando Migliaccio4f11ff32016-10-27 06:15:23 -070098 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 Thangappa7c573062015-02-18 01:51:13 -0800101
Michael Johnson8b9864d2019-01-24 10:49:35 -0800102Set up a simple web server on each of these instances. ssh into each instance (username 'cirros', password 'cubswin:)' or 'gocubsgo') and run
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800103
David Rabelc77c9492018-04-05 20:56:22 +0200104::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800105
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 Johnson8b9864d2019-01-24 10:49:35 -0800109Phase 2: Create your load balancer
110----------------------------------
111
112Make sure you have the 'openstack loadbalancer' commands:
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800113
David Rabelc77c9492018-04-05 20:56:22 +0200114::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800115
Michael Johnson8b9864d2019-01-24 10:49:35 -0800116 pip install python-octaviaclient
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800117
Michael Johnson8b9864d2019-01-24 10:49:35 -0800118Create 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
134Please note: The <web server # address> fields are the IP addresses of the nova
135servers created in Phase 1.
136Also note, using the API directly you can do all of the above commands in one
137API call.
138
139Phase 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
148This should show the "Welcome to <IP>" message from each member server.