python-libraclient/doc/examples.rst
David Shrewsbury 6690e8a5ef Add support for key=value node options
This changes allows additional node options to be defined after
the ip:port portion. Format will be:

IP:PORT:key=value:key=value:...

First two node options supported are 'weight' and 'backup'.

Also fixes a minor bug where 'raise' was being called without
defining what type of exception to raise. This works ok to re-raise
an existing exception, but raising a new exception requires a type.

Change-Id: I9b9883d100983a242002c95378bdbb672937ed90
2013-09-30 13:17:08 -04:00

6.8 KiB

Examples

Create Load Balancer

libra_client --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region create --name=my_load_balancer \
--node 192.168.1.1:80 --node 192.168.1.2:80

This example will create a basic load balancer which will listen on port 80 and direct traffic in a round-robin fashion to two nodes, 192.168.1.1 and 192.168.1.2. Both these nodes are web servers listening on port 80. The Libra Client will then return a table similar to the below:

ID

Name

Protocol Port

Algorithm

Status

Created

Updated

1157 my_load_balancer

HTTP

80

ROUND_ROBIN BUILD 2013-01-10T14:41Z 2013-01-10T14:41Z

IPs

Nodes

[{u'ipVersion': u'IPV_4', u'type': u'PUBLIC', u'id': u'52', u'address': u'15.185.224.62'}] [{u'status': u'ONLINE', u'id': u'2311', u'port': u'80', u'condition': u'ENABLED', u'address': u'192.168.1.1'}, {u'status': u'ONLINE', u'id': u'2312', u'port': u'80', u'condition': u'ENABLED', u'address': u'192.168.1.2'}]

Create a Load Balancer with Node Options

libra_client --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region create --name=my_load_balancer \
--node 192.168.1.1:80:weight=1 --node 192.168.1.2:80:weight=2

Nearly identical to the above example, this creates a new load balancer with two nodes, but one is more heavily weighted than the other, causing it to accept more traffic.

Create a Shared Load Balancer

It is possible for a single logical load balancer to balancer traffic for both HTTP and HTTPS for a site. For this example we will add an HTTPS load balancer to the load balancer we created previously:

libra_client --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region create --name=my_load_balancer \
--node 192.168.1.1:443 --node 192.168.1.2:443 --protocol=TCP --port=443 \
--vip=52

We have taken the IP ID which was provided in the original create and given this as a VIP number in the command. We are also setting to TCP mode so the SSL termination happens at the web server and set the load balancer to listen on port 443. The result is as follows:

ID

Name

Protocol Port

Algorithm

Status

Created

Updated

1158 my_load_balancer

TCP

443 ROUND_ROBIN BUILD 2013-01-10T14:44Z 2013-01-10T14:44Z

IPs

Nodes

[{u'ipVersion': u'IPV_4', u'type': u'PUBLIC', u'id': u'52', u'address': u'15.185.224.62'}] [{u'status': u'ONLINE', u'id': u'2313', u'port': u'443', u'condition': u'ENABLED', u'address': u'192.168.1.1'}, {u'status': u'ONLINE', u'id': u'2314', u'port': u'443', u'condition': u'ENABLED', u'address': u'192.168.1.2'}]

Add a Node

libra_client --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region node-add --id=1158 --node=192.168.1.3:443

In this example we have take the ID of the load balancer of the previos example to add a web server to. The result should look something like this:

ID

Address

Port Condition Status
192.168.1.3 443