Jump to: navigation, search

Difference between revisions of "Neutron/LBaaS/HowToRun"

< Neutron‎ | LBaaS
m (Add which section in quantum.conf to edit service_plugins)
(Topology Setup)
Line 62: Line 62:
 
Get the UUID of the private subnet.   
 
Get the UUID of the private subnet.   
  
<pre>quantum subnet-list</pre>
+
<pre>neutron subnet-list</pre>
  
 
Create a Pool:  
 
Create a Pool:  
  
<pre>quantum lb-pool-create --lb-method ROUND_ROBIN --name mypool --protocol HTTP --subnet-id <subnet-id> </pre>  
+
<pre>neutron lb-pool-create --lb-method ROUND_ROBIN --name mypool --protocol HTTP --subnet-id <subnet-id> </pre>  
  
 
Create Members (using the IPs of server1 and server2):  
 
Create Members (using the IPs of server1 and server2):  
Line 73: Line 73:
 
<pre>nova list  
 
<pre>nova list  
  
quantum lb-member-create --address <server1-ip> --protocol-port 80 mypool
+
neutron lb-member-create --address <server1-ip> --protocol-port 80 mypool
quantum lb-member-create --address <server2-ip> --protocol-port 80 mypool</pre>
+
neutron lb-member-create --address <server2-ip> --protocol-port 80 mypool</pre>
  
 
Create a Healthmonitor and associated it with the pool:  
 
Create a Healthmonitor and associated it with the pool:  
  
<pre>quantum lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
+
<pre>neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
quantum lb-healthmonitor-associate <healthmonitor-uuid> mypool</pre>  
+
neutron lb-healthmonitor-associate <healthmonitor-uuid> mypool</pre>  
  
 
Create a VIP
 
Create a VIP
  
<pre>quantum lb-vip-create --name myvip --protocol-port 80 --protocol HTTP --subnet-id <subnet-id> mypool</pre>  
+
<pre>neutron lb-vip-create --name myvip --protocol-port 80 --protocol HTTP --subnet-id <subnet-id> mypool</pre>  
  
note the address for use below.
+
note the address for use below.
  
 
== Validation ==  
 
== Validation ==  

Revision as of 10:46, 14 October 2013

Getting the Code

LBaaS introduces changes in the following modules: (currently all changes are in master branch)

  • quantum
  • python-quantumclient
  • horizon
  • devstack

Devstack Setup

Add the following lines to your localrc:

enable_service q-lbaas

Then run stack.sh

After stack.sh completes you'll be able to manage your Load Balancer via the CLI tools and within Horizon

Ubuntu Packages Setup

Install the quantum-lbaas-agent and haproxy:

sudo apt-get install quantum-lbaas-agent haproxy

Once packages are installed make the directory for the LBaaS service and copy the configuration into place:

sudo mkdir -p /etc/quantum/plugins/services/agent_loadbalancer/
sudo cp /etc/quantum/lbaas_agent.ini /etc/quantum/plugins/services/agent_loadbalancer/lbaas_agent.ini

And edit the service_plugins in [DEFAULT] section in quantum.conf to enable the service:

sudo sed -i.bak "s/\#\ service_plugins\ \=/service_plugins = quantum.plugins.services.agent_loadbalancer.plugin.LoadBalancerPlugin/g" /etc/quantum/quantum.conf
Finally enable the Load Balancer section in Horizon by editing
/etc/openstack-dashboard/local_settings.py
and changing:
OPENSTACK_QUANTUM_NETWORK = {
    'enable_lb': False
}

to

OPENSTACK_QUANTUM_NETWORK = {
    'enable_lb': True
}

Once done restart your Quantum services and Apache to start using.

Topology Setup

Spin up three VMs, two to be servers, and one to be a client.

nova boot --image <image-uuid> --flavor 1 server1
nova boot --image <image-uuid> --flavor 1 server2
nova boot --image <image-uuid> --flavor 1 client

Get the UUID of the private subnet.

neutron subnet-list

Create a Pool:

neutron lb-pool-create --lb-method ROUND_ROBIN --name mypool --protocol HTTP --subnet-id <subnet-id> 

Create Members (using the IPs of server1 and server2):


nova list 

neutron lb-member-create --address <server1-ip> --protocol-port 80 mypool
neutron lb-member-create --address <server2-ip> --protocol-port 80 mypool

Create a Healthmonitor and associated it with the pool:

neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
neutron lb-healthmonitor-associate <healthmonitor-uuid> mypool

Create a VIP

neutron lb-vip-create --name myvip --protocol-port 80 --protocol HTTP --subnet-id <subnet-id> mypool

note the address for use below.

Validation

We now have two hosts with a load balancer pointed at them, but those hosts are serving up any HTTP content.

A simple trick is to use netcat on the hosts to implement a simple webserver. For example, run:

while true; do echo -e 'HTTP/1.0 200 OK\r\n\r\n<servername>' | sudo nc -l -p 80 ; done 

replacing <servername> with "server1" and "server2" as appropriate. Once the server is started, you'll see incoming HTTP GET requests.. that's the load balancer health check in action!

If you have python installed, you can also create an index.html with the text "server1" or "server2" then in the same directory run: python -m SimpleHTTPServer)

Finally, to test real load balancing, from your client, use wget to make sure your requests are load-balanced across server1 and server2 as expected.

wget -O - http://<server1-ip> 
wget -O - http://<server2-ip> 

Then use wget to hit the VIP IP several times in succession. You should bounce between seeing server1 and server2.

wget -O - http://<vip-ip> 
wget -O - http://<vip-ip> 
wget -O - http://<vip-ip> 
wget -O - http://<vip-ip> 

Full list of LBaaS CLI commands is available at Quantum/LBaaS/CLI

Troubleshooting

LBaas is implemented similar to L3 + DHCP using namespaces. You can use "ip netns list" to find the namespace named qlbaas-<pool_id>, and then test connectivity from that namespace.

Use "screen -x stack" to view the q-svc and q-lbaas tabs for errors.

Grep syslog for "haproxy" to see messages from Haproxy (though they are quite cryptic!)