Load Balancer as a Service – Part 1

Creation of an IP Address POOL for the VIPs

Here we want to create a pool of IPs.
Later on, one IP will be chosen dynamically from this pool for each new Virtual Server.
This specific IP is called Virtual IP (VIP).
->These calls don’t need to be automated.


At first, we need to create one or more IP blocks which contain our subnet (10.110.1.0/24)

PATCH https://<nsx-mgr>/policy/api/v1/infra/ip-blocks/LB-VIP-ITSERVICES-Prod
{
"cidr": "10.110.1.0/24",
"resource_type": "IpAddressBlock",
"display_name": "LB-VIP-ITSERVICES-Prod",
"marked_for_delete": false
}


Secondly, we create a new IP Address Pool.

PATCH https://<nsx-mgr>/policy/api/v1/infra/ip-pools/LB-VIP-ITSERVICES-Prod
{
"resource_type": "IpAddressPool",
"display_name": "LB-VIP-ITSERVICES-Prod",
"marked_for_delete": false
}


Finally, we attach the IP Blocks to the newly created IP Address Pool.

PATCH https:///policy/api/v1/infra/ip-pools/LB-VIP-ITSERVICES-Prod/ip-subnets/Subnet-1
{
"size":"256",
"ip_block_path": "/infra/ip-blocks/LB-VIP-ITSERVICES-Prod",
"auto_assign_gateway": true,
"resource_type": "IpAddressPoolBlockSubnet",
"display_name": "Subnet-1",
"marked_for_delete": false
}


Allocation of an IP in an IP Address POOL

Now that we have our IP Address Pool ready, we are going to take one IP for our Virtual Server.
Note: The IPs “.0” and “.1” are reserved. So in our case, the first IP which can be allocate is 10.110.1.2.

First we need to know the ID of our IP Address Pool.
GET https://<nsx-mgr>/api/v1/pools/ip-pools/

{
"id": "5ca0f55c-d4c6-4b40-9e21-6e57ed5044bd",
"display_name": "LB-VIP-ITSERVICES-Prod"
}

We can now allocate an IP from this pool.
POST https://<nsx-mgr>/api/v1/pools/ip-pools/5ca0f55c-d4c6-4b40-9e21-6e57ed5044bd?action=ALLOCATE

{
"allocation_id":null
}
RESPONSE:
{
  "allocation_id": "10.110.1.2",
  "_protection": "NOT_PROTECTED"
}

The same way we can also release an IP from the pool.
NOTE: It takes some time (up to 5 minutes) after sending the request before you can actually see the IP released in the GUI.
POST https://<nsx-mgr>/api/v1/pools/ip-pools/5ca0f55c-d4c6-4b40-9e21-6e57ed5044bd?action=RELEASE

{
"allocation_id": "10.110.1.2"
}

Leave a Comment