Skip to content

Load Balancers

In HyperCloud, the Virtual Router Template can be set up as a Load Balancer; it is also possible to set up multiple instances to make the Service highly available.

Ensure that the Service Virtual Router has been downloaded from the marketplace.

These instructions use the auto-scaling web service created by following those instructions: Auto-Scaling Services

Info

Take note that, in the environment created below, a static route has been added to get back to the jump host used for testing, this should not be compulsory for production environments.

  1. Navigate to Templates -> Virtual Routers, where the Template for Service Virtual Router resides.
  2. Click on the Template and green dropdown button to Instantiate a new Virtual Router.
  3. Input a Name.
  4. Add two network interfaces.

    • One in the web cluster network.
    • The other in a network accessible to the test host.
    • Add security groups for each NIC.

    Instantiate Virtual Router

  5. Scroll down and click the radio button Yes to enable the Load Balancer function.

    • Enter the following in the Load Balancer JSON configuration box:
{ "index": 0, "real-servers": [ { "server-host": "10.199.0.12" }, { "server-host": "10.199.0.13" }, { "server-host": "10.199.0.14" } ], "lb-address": "172.16.60.11" }

Info

  • index = 0, this is the Load Balancer ID, this will need to be changed for each Load Balancer added, if High Availability is required.
  • server-host(s) are the IP Addresses of the VM Cluster, one for each (note the addresses of the reservation created prior)
  • lb-address is the public facing IP Address of the Load Balancer

Enable Load Balancer

The JSON configuration above is the most basic setup possible which will try to forward all traffic to one of the Cluster Hosts including SSH. If SSH access to the Load Balancer is desired, a third NIC will be required or the use of a more detailed configuration, as seen below:

{ "index": 0, "real-servers": [ { "server-host": "10.199.0.12", "server-port": "80" }, { "server-host": "10.199.0.13", "server-port": "80" }, { "server-host": "10.199.0.14", "server-port": "80" } ], "lb-address": "172.16.60.11" }
  1. Scroll to the top of the page and click the green Instantiate button to instantiate the Load Balancer.

The new Load Balancer should now be present in both Instances -> VMs and Instances -> Virtual Routers. - Wait for the device to start up and ensure it is forwarding traffic via the client:

jumphost:~ # curl http://172.16.60.11
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>HTML5</title>
</head>
<body>
    Server is web-scaler-2--service-12
</body>
</html>
  1. Once the device is verified to be working, trigger the scaling of the auto-scaling web service.

  2. When all three VMs are running, test the Load Balancer to ensure a different Host is presented each time the request is sent:

    jumphost:~ # curl http://172.16.60.11
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>HTML5</title>
    </head>
    <body>
        Server is web-scaler-1--service-12
    </body>
    </html>
    
    jumphost:~ # curl http://172.16.60.11
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>HTML5</title>
    </head>
    <body>
        Server is web-scaler-0--service-12
    </body>
    </html>
    
    jumphost:~ # curl http://172.16.60.11
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>HTML5</title>
    </head>
    <body>
        Server is web-scaler-2--service-12
    </body>
    </html>
    
  3. The Load Balancer is now set up and working.