• Elastic Load Balancing

elb
  1. Help Center
  2. Elastic Load Balancing
  3. API Reference
  4. Enhanced Load Balancer APIs
  5. Load Balancer
  6. Creating a Load Balancer

Creating a Load Balancer

Function

This API is used to create a private network load balancer. After the load balancer is created, its information is returned such as load balancer ID, load balancer IP address, and subnet ID.

To create a public network load balancer, you also need to call the API for assigning a floating IP address and associate the floating IP address to the ID of the port bound to the IP address of the private network load balancer.

URI

POST /v2.0/lbaas/loadbalancers

Request

Table 1 Parameter description

Parameter

Type

Mandatory

Description

loadbalancer

Dict

Yes

Specifies the load balancer. For details, see Table 2.

Table 2 loadbalancer field description

Parameter

Type

Mandatory

Description

name

String (255)

No

Specifies the load balancer name.

description

String (255)

No

Provides supplementary information about the load balancer.

tenant_id

String (255)

No

Specifies the ID of the project where the load balancer is used.

The value must be the same as the value of project_id in the token.

vip_subnet_id

Uuid

Yes

Specifies the ID of the subnet where the load balancer works. Obtain the value by listing the subnets. The load balancer IP address is in this subnet.

Only IPv4 subnets are supported.

provider

String

No

Specifies the provider of the load balancer.

The value can only be vlb.

vip_address

String (64)

No

Specifies the IP address of the load balancer.

This IP address must be the one in the subnet specified by vip_subnet_id. If this parameter is not specified, an IP address is automatically assigned to the load balancer from the subnet specified by vip_subnet_id.

admin_state_up

Bool

No

Specifies the administrative status of the load balancer.

This parameter is reserved and has been not used. The default value is true.

Response

Table 3 Parameter description

Parameter

Type

Description

loadbalancer

Dict

Specifies the load balancer. For details, see Table 4.

Table 4 loadbalancer field description

Parameter

Type

Description

id

Uuid

Specifies the load balancer ID.

tenant_id

String (255)

Specifies the ID of the project where the load balancer is used.

name

String (255)

Specifies the load balancer name.

description

String (255)

Provides supplementary information about the load balancer.

vip_subnet_id

Uuid

Specifies the ID of the subnet where the load balancer works.

vip_port_id

Uuid

Specifies the ID of the port bound to the load balancer IP address.

provider

String

Specifies the provider of the load balancer.

vip_address

String (64)

Specifies the IP address of the load balancer.

listeners

List

Lists the IDs of listeners added to the load balancer.

pools

List

Lists the IDs of backend server groups associated with the load balancer.

operating_status

String (16)

Specifies the operating status of the load balancer.

The value can be ONLINE, OFFLINE, DEGRADED, DISABLED, or NO_MONITOR.

This parameter is reserved and has been not used. The default value is ONLINE.

provisioning_status

String (16)

Specifies the provisioning status of the load balancer.

The value can be ACTIVE, PENDING_CREATE, or ERROR.

This parameter is reserved and has been not used. The default value is ACTIVE.

admin_state_up

Bool

Specifies the administrative status of the load balancer.

This parameter is reserved and has been not used. The default value is true.

tags

List

Lists load balancer tags.

created_at

String (19)

Specifies the time when the load balancer was created.

The time is in YYYY-MM-DDTHH:MM:SS format.

updated_at

String (19)

Specifies the time when the load balancer was updated.

The time is in YYYY-MM-DDTHH:MM:SS format.

Example

  • Example request 1: Creating a private network load balancer
    POST https://{Endpoint}/v2.0/lbaas/loadbalancers 
    
    { 
        "loadbalancer": { 
            "name": "loadbalancer1", 
            "description": "simple lb", 
            "tenant_id": "1867112d054b427e808cc6096d8193a1", 
            "vip_subnet_id": "58077bdb-d470-424b-8c45-2e3c65060a5b", 
            "vip_address": "192.168.0.100", 
            "admin_state_up": true 
        } 
    }
  • Example response 1
    {
        "loadbalancer": {
            "description": "simple lb",
            "provisioning_status": "ACTIVE",
            "tenant_id": "1867112d054b427e808cc6096d8193a1",
            
            "created_at": "2019-01-19T05:32:56",
            "admin_state_up": true,
            "updated_at": "2019-01-19T05:32:57",
            "id": "ea2843da-4026-49ec-8338-8fa015b067fc",
            "pools": [],
            "listeners": [],
            "vip_port_id": "a7ecbdb5-5a63-41dd-a830-e16c0a7e04a7",
            "operating_status": "ONLINE",
            "vip_address": "192.168.0.100",
            "vip_subnet_id": "58077bdb-d470-424b-8c45-2e3c65060a5b",
            "provider": "vlb",
            "tags": [],
            "name": "loadbalancer1"
        }
    }
  • Example request 2: Creating a public network load balancer

    Bind a floating IP address to the port bound to the IP address of the private network load balancer. For details about the parameters, see Table 5.

    Table 5 floatingip field description

    Parameter

    Type

    Mandatory

    Description

    floatingip

    Dict

    Yes

    Specifies the floating IP address list. For details, see Table 6.

    Mandatory field: floating_network_id

    Table 6 Floating IP address object

    Attribute

    Mandatory

    Type

    CRUD

    Default Value

    Constraint

    Description

    status

    No

    String

    R

    DOWN

    N/A

    Specifies the network status. The value can be ACTIVE, DOWN, or ERROR.

    id

    Yes

    Uuid-str

    R

    Automatically generated

    N/A

    Specifies the floating IP address ID.

    This parameter is not required when you assign a floating IP address.

    floating_ip_address

    No

    String(64)

    CR

    None

    N/A

    Specifies the floating IP address.

    floating_network_id

    No

    Uuid-str

    CR

    N/A

    N/A

    Specifies the external network ID.

    You can only use fixed external network. You can use GET /v2.0/networks?router:external=True or GET /v2.0/networks?name={floating_network} or run the neutron net-external-list command to obtain information about the external network.

    router_id

    No

    Uuid-str

    R

    None

    N/A

    Specifies the ID of the belonged router.

    port_id

    No

    Uuid-str

    CRU

    None

    N/A

    Specifies the port ID.

    fixed_ip_address

    No

    String(64)

    R

    None

    IP address or none

    Specifies the private IP address of the associated port.

    tenant_id

    No

    String(255)

    R

    ID of the authenticated tenant

    N/A

    Specifies the project ID.

    dns_name

    No

    String(255)

    R

    None

    N/A

    Specifies the DNS name.

    dns_domain

    No

    String(255)

    R

    None

    N/A

    Specifies the DNS domain.

    project_id

    No

    String(64)

    R

    N/A

    N/A

    Specifies the project ID of a resource.

    created_at

    No

    String(64)

    R

    Automatically generated

    N/A

    Specifies the time when the resource was created.

    updated_at

    No

    String(64)

    R

    Automatically generated

    N/A

    Specifies the time when the resource was updated.

    • Step 1 example request (Obtain the ID of the public network. This ID will be associated with the floating IP address after it is assigned.)
      GET https://{VPC Endpoint}/v2.0/networks?router:external=True
    • Step 1 example response
      {
          "networks": [
              {
                  "id": "0a2228f2-7f8a-45f1-8e09-9039e1d09975",
                  "name": "admin_external_net",
                  "status": "ACTIVE",
                  "shared": true,
                  "subnets": [],
                  "availability_zone_hints": [],
                  "availability_zones": [
                      "kvmxen.dc1",
                      "az1.dc1",
                      "dc2",
                      "ceshishouqing"
                  ],
                  "admin_state_up": true,
                  "tenant_id": "4b7a4342e4b54d1590cfa088318ad732",
                  "project_id": "4b7a4342e4b54d1590cfa088318ad732",
                  "provider:network_type": "vlan",
                  "router:external": true,
                  "created_at": "2017-04-24T13:59:52",
                  "updated_at": "2017-04-24T13:59:52"
              }
          ]
      }
    • Step 2 example request (Bind the floating IP address. floating_network_id indicates the network ID queried in ▪ Step 1 example response, and port_id is vip_port_id in ▪ Example response 1.)
      POST https://{VPC Endpoint}/v2.0/floatingips
      
      {
          "floatingip": {
                 "floating_network_id": "0a2228f2-7f8a-45f1-8e09-9039e1d09975",
                 "port_id": "a7ecbdb5-5a63-41dd-a830-e16c0a7e04a7"
          }
      }
    • Step 2 example response
      {
          "floatingip": {
              "id": "0df9bcd8-dfb1-4685-8a3f-e01fbf7f87e4",
              "status": "DOWN",
              "router_id": "f066a5e4-4af6-4434-aec4-6d3289326f9c",
              "tenant_id": "601240b9c5c94059b63d484c92cfe308",
              "project_id": "601240b9c5c94059b63d484c92cfe308",
              "floating_network_id": "0a2228f2-7f8a-45f1-8e09-9039e1d09975",
              "fixed_ip_address": "192.168.0.100",
              "floating_ip_address": "10.154.196.145",
              "port_id": "a7ecbdb5-5a63-41dd-a830-e16c0a7e04a7",
              
              
              "created_at": "2019-01-19T05:36:44",
              "updated_at": "2019-01-19T05:36:44"
          }
      }
    • After the preceding steps are complete, the load balancer has the capability of accessing the public network. You can access the load balancer using the configured floating IP address (10.154.196.145).

Response Codes

For details, see HTTP Status Codes for Enhanced Load Balancers.