In order to setup a loadbalancer, you may proceed as follows using CLI commands:
First, you will need to know the name or ID of your subnet. Use neutron subnet-list and use the default internal network provided, or any other subnet you have created. Note all your instances to be loadbalanced must also be within this subnet.
$ neutron lbaas-loadbalancer-create --name test-lb
Next use the following command to create the loadbalancer listener. This example is for basic http connections:
$ neutron lbaas-listener-create --name test-lb-http --loadbalancer test-lb --protocol HTTP --protocol-port 80
Now add create a pool, and add instances to it. They are called 'members' and are added using their internal (fixed) IPs:
$ neutron lbaas-pool-create --name test-lb-pool-http --lb-algorithm ROUND_ROBIN --listener test-lb-http --protocol HTTP
$ neutron lbaas-member-create --name test-lb-http-member-1 --subnet private-subnet --address {instance1-fixed-ip} --protocol-port 80 test-lb-pool-http
$ neutron lbaas-member-create --name test-lb-http-member-2 --subnet private-subnet --address {instance2-fixed-ip} --protocol-port 80 test-lb-pool-http
Add a floating IP to the loadbalancer:
$ neutron floatingip-associate FLOATINGIP_ID LOAD_BALANCER_PORT_ID
To get the floatingip_id use neutron floatingip-list and to get the loadbalancer port use neutron lbaas-loadbalancer-show {loadblanacerid}
Now try curling the IP to see if
Finally add a healthmonitor. This will auto remove instances from the pool if they are down or unresponsive:
neutron lbaas-healthmonitor-create --name test-lb-http-monitor --delay 5 --max-retries 2 --timeout 10 --type HTTP --pool test-lb-pool-http
Once complete your instances will be loadbalanced.
|