Introduction
This documents gives an overview to the design and functional implementation for Internal Load Balancing on VPC tiers.
Feature developers:
- APIs and Business logic - Alena Prokharchyk
- Backend - TBA
- UI - TBA
Glossary
- Internal LB - the load balancing between internal (guest) cloudStack networks
- Internal LB Rule- Load balancer rule with the front end IP from Internal (Guest) cloudStack network.
- Internal LB VM - cloudStack system vm managing internal LB Rules
Use case
There are 2 tiers in the VPC - Web tier and Application tier. Traffic to Web tier is balanced on the VPC VR on the public side. User wants traffic coming from Web to the App tier to be balanced as well. Load balancing on the App tier will be covered by the Internal LB feature.
Internal LB can be handled by 2 network providers:
- InternalLBVm - have to add support for this provider first.
- Netscaler VPX
The pic below is for the case when InternalLBVm is used as a provider for the LB service on internal tier:
- Public LB rule for 72.52.125.10 Public IP, public port 80 and private port 81. It enables LB for traffic coming from the internet to the vms on the Web tier. The LB rule is configured on the VPC VR.
- Internal LB rule #1 for 10.10.10.4 guest IP, loadBalancerPort 23 and instancePort 25. The LB rule is configured on InternalLBVM1.
- Internal LB rule #2 for 10.10.10.4 guest IP, loadBalancerPort 45 and instancePort 46. The LB rule is configured on InternalLBVM1.
- Internal LB rule #3 for 10.10.10.6 guest IP, loadBalancerPort 23 and instancePort 25. The LB rule is configured on InternalLBVM2.

General flow
1) Enable Internal LB on VPC tier
In order to have Internal Load Balancing support on VPC tier, the tier has to be created from the network offering with:
- Service=LB, Provider=InternalLBVm, Schema=InternalLb
or
- Service=LB, Provider=Netscaler, Schema=InternalLb
Java code changes
- Introduce Schema concept for the Network Service. Service can support multiple schemas, and each schema can have a separate provider.
- Network.java interface - add new capability for the LB service - schema. It will have 2 values - Internal and External.
- Existing Netscaler Service Provider will support both values - Internal and External - for the "schema" capability as it can act as a provider for External and Internal Load Balancing.
- Introduce new Network Element - InternalLBVm. This provider supports only 1 service - LB, and its "schema" capability can be Internal only. We need a new network element because Internal LB Vm will have different number of nics from the regular CS system vm (Guest and Control only); and its lifecycle will be different as well. The Vm will be started not when network gets implemented, but when the new IP gets acquired from the Guest Network for the Load Balancer rule.
- Introduce InternalLBNetworkApplianceManager - for managing Internal Load Balancer vms.
Backend changes
TBD. We might need a separate template/set of scripts for Internal LB VM, or we can re-use the existing VR template.
Web Services API
Changes to existing APIs
Api Name |
Request Parameters |
Response Parameters |
Available to regular user |
createNetworkOffering |
serviceProviderList - will accept "schema" (optional) as one of the list items
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0b5409bf-b3f8-45a8-82ee-5bdaa01cd8d1"><ac:plain-text-body><![CDATA[example: serviceProviderList[0].service=Lb&serviceProviderList[0].schema=internalLb&serviceProviderList[0].provider=Netscaler |
List of child objects "schema" will be added to the response. Each "schema" object will have parameters: ]]></ac:plain-text-body></ac:structured-macro>
|
No |
DB changes
- "schema" field is added to ntwk_service_map and ntwk_offering_service_map tables.
- During the DB upgrade schema should be set to NULL for all serivce/provider mappings, except for LB. For the LB service/provider, its value should be set to ExternalLb
2) Create Load Balancer Rule
Java code changes
- Add new manager - InternalLoadBalancerManagerImpl (name is TBD). This class will be responsible for managing Internal LB rules.
- The LBRule can be created with or without specifying the source IP address. If no source IP address is specified, the new one will get acquired automatically from the guest network, and assigned to the LB rule.
- Internal LB rule creation will be allowed only for the network where LB Service supports Schema=InternalLb
If provider is InternalLBVM:
- A new InternalLBVM should be spanned as soon as new source IP address is acquired by the LB rule. This code should be handled by InternalLBNetworkApplianceManager. See more details on the VM in "InternalLBVM management and life cycle" section.
- There is going to be 1 Internal LB vm spanned per guest IP address participating in the Internal Load Balancing. If more rules are added for the same IP, they will be managed on the same InternalLBVM.
If LB provider is Netscaler VPX:
Backend changes
TBD. For InternalLBVM, have to put HA proxy management/configuration details here
Web Services API
Changes to existing APIs
API Name |
Request Parameters |
Response parameters |
Available to regular user |
createLoadBalancingRule |
New parameters:
- schema (String enum, optional with External/Internal choices; optional; =External by default)
- sourceIpAddress (String, optional, can be used only with networkId conjunction) If networkId=(guestNetworkId of the network where internal LB is supported) is passed in w/o sourceIpAddress param,
the IP address from the guest network will get acquired on the fly and be assigned to the Load Balancing Rule.
|
New parameters:
|
yes |
listLoadBalancingRules |
New parameters:
|
New parameters:
|
yes |
DB changes
Existing table load_balancing_rules will get a new field - "schema". It will have "External" value by default, and will accept enum values External/Internal.
3) Assign VMs to the Internal Load Balancer.
Existing set of APIs will be used for adding/deleting VMs to/from Internal LB Rule.
- assignToLoadBalancerRule
- deleteFromLoadBalancerRule
How to list Guest IP addresses allocated for LB purpose
Web Services API
At the moment, cloudStack doesn't expose any API for listing IP addresses from the guest network. Adding a new one to serve this purpose:
API Name |
Request Parameters |
Response Parameters |
Available to regular user |
listIpAddresses |
- ipAddress
- networkId
- purpose
|
list of ip Addresses, each IP object having parameter:
- ipAddress
- networkId
- purpose (can have value "LB" at this point)
- state (Free/Allocated)
|
true |
In 4.2 this API will return only Allocated IP addresses.
DB changes
Introduce new table ip_address having fields:
- id
- uuid
- ip_address
- network_id
- allocated
- purpose (can be VM or LBRule in 4.2 as Ips from the guest network can be allocated only for these 2 purposes)
Internal Load Balancing Vm management and life cycle
1) The InternalLBVM will be created with 2 interfaces: eth0 - linkLocal (private in VMWare case), eth1 - the IP address of the LB rule.
3) InternalLBVM will be managed by InternalLBNetworkApplianceManager
2) InternalLBVM life cycle:
- Create: InternalLBVM gets created when the first Load Balancing Rule is created for the IP address
- Destroy: InternalLBVM gets destroyed when the last Load Balancer is removed for the IP address
- Reboot: InternalLBVM can be rebooted as a regular system vm using RebootSystemVm API.
- List: InternalLBVM can be listed with ListSystemVMs API
Limitations
- Internal and Public Lb are mutually exclusive on a tier. If the tier has LB on the public side, then it can't have the Internal LB
- Supported just on VPC networks
UI
TBD