Create Load Balancer
/v2/lbaas/loadbalancersCreates a load balancer, and optionally its listener, pool, health monitor, and members in the same request. The load balancer is provisioned asynchronously: it returns PENDING_CREATE and becomes usable when its status reaches ACTIVE.
Source: create-a-load-balancer
Request
Parameters
loadbalancerobjectrequiredLoad balancer wrapper.
12 fields
namestringbodyHuman-readable name.
descriptionstringbodyFree-form description.
vip_subnet_idstringbodySubnet for the VIP. One of vip_subnet_id, vip_network_id, or vip_port_id is required.
vip_network_idstringbodyNetwork for the VIP. One of the three VIP fields is required.
vip_port_idstringbodyExisting port for the VIP. One of the three VIP fields is required.
vip_addressstringbodySpecific IP address for the VIP.
vip_ip_versionintegerbody4 or 6. Default: 4.
2 values
4IPv4 VIP.6IPv6 VIP.
providerstringbodyProvider driver. Default: octavia.
flavor_idstringbodyLoad balancer flavor ID, if your project has one.
admin_state_upbooleanbodyAdministrative state. Default: true.
tagsarraybodyTags on the resource.
listenersarraybodyListeners to create with the load balancer.
4 fields
namestringbodyListener name.
protocolstringrequiredbodyHTTP, HTTPS, TCP, UDP, and similar.
4 values
HTTPHTTP traffic.HTTPSHTTP over TLS.TCPTCP passthrough, without inspecting the payload.UDPUDP datagrams.
protocol_portintegerrequiredbodyPort the listener accepts traffic on.
default_poolobjectbodyPool to create and bind as the listener default pool.
5 fields
namestringbodyPool name.
protocolstringrequiredbodyPool protocol, for example HTTP.
4 values
HTTPPool members speak HTTP.HTTPSPool members speak HTTPS.TCPTCP passthrough to members.UDPUDP to members.
lb_algorithmstringbodyROUND_ROBIN, LEAST_CONNECTIONS, or SOURCE_IP.
3 values
ROUND_ROBINDistributes new connections evenly across members.LEAST_CONNECTIONSSends new connections to the member with the fewest active connections.SOURCE_IPHashes the source address to pick a member, so a client sticks to the same member.
healthmonitorobjectbodyHealth monitor for the pool.
4 fields
typestringrequiredbodyHTTP, HTTPS, TCP, PING, and similar.
4 values
HTTPSends an HTTP request and expects a successful response.HTTPSSends an HTTPS request and expects a successful response.TCPChecks that the member accepts a TCP connection.PINGSends ICMP echo requests.
delayintegerrequiredbodySeconds between checks.
timeoutintegerrequiredbodySeconds before a check times out.
max_retriesintegerrequiredbodyFailed checks before a member is marked down.
membersarraybodyBackend members.
2 fields
addressstringrequiredbodyMember IP address.
protocol_portintegerrequiredbodyMember port.
Sample Request
curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d '{
"loadbalancer": {
"name": "lb2",
"vip_subnet_id": "fd2de462-f93b-43a6-9b5c-254f1e690bf1",
"listeners": [
{
"name": "http_listener",
"protocol": "HTTP",
"protocol_port": 80,
"default_pool": {
"name": "rr_pool",
"protocol": "HTTP",
"lb_algorithm": "ROUND_ROBIN",
"healthmonitor": {
"type": "HTTP",
"delay": 3,
"timeout": 1,
"max_retries": 2
},
"members": [
{"address": "192.168.10.245", "protocol_port": 80},
{"address": "192.168.10.168", "protocol_port": 80}
]
}
}
]
}
}' https://api.vietnix.cloud:9888/v2/lbaas/loadbalancers
Response
Sample Response
Response body
{
"loadbalancer": {
"id": "3f2a1b9c-6d4e-4f70-8a11-2c3d4e5f6a70",
"name": "lb2",
"provisioning_status": "PENDING_CREATE",
"operating_status": "OFFLINE",
"provider": "amphora",
"vip_address": "192.168.10.5",
"vip_subnet_id": "fd2de462-f93b-43a6-9b5c-254f1e690bf1",
"vip_network_id": "15f7dc0a-712c-422f-bfd3-31dc351d9026",
"vip_port_id": "fb0e8e3e-2a71-420a-885c-94f6d2c2f2b7",
"listeners": [
{"id": "1dc8539c-7545-4ae8-8081-3140a47b6342"}
],
"pools": [
{"id": "bd04cc50-0575-45cc-a965-514357a4b62d"}
],
"admin_state_up": true,
"tags": []
}
}
Status Code
Success
| Status Code | Description |
|---|---|
| 201 - Created | The load balancer was created and provisioning started. |
Error
| Status Code | Description |
|---|---|
| 400 - Bad Request | Some content in the request was invalid, for example no VIP field. |
| 401 - Unauthorized | User must authenticate before making a request. |
| 403 - Forbidden | Policy does not allow current user to do this operation. |
| 404 - Not Found | The subnet, network, or port does not exist. |
| 500 - Internal Server Error | The service failed to process the request. |
| 503 - Service Unavailable | The load balancing service is not available. |
The VIP is a private address. To publish the service, create a floating IP and associate it with vip_port_id (see Update Floating IP).