Creating a Load Balancer

Function

This API is used to create a load balancer. When you create the load balancer, note the following:

  • Specify both vip_subnet_cidr_id and vip_address if you want to bind a private IPv4 address to the load balancer.

  • Specify publicip and either vpc_id or vip_subnet_cidr_id if you want to bind a new IPv4 EIP to the load balancer.

  • Specify publicip_ids and either vpc_id or vip_subnet_cidr_id if you want to bind an existing IPv4 EIP to the load balancer.

  • Specify ipv6_vip_virsubnet_id you want to bind a private IPv6 address to the load balancer.

  • Specify ipv6_vip_virsubnet_id and ipv6_bandwidth if you want to bind a public IPv6 address to the load balancer.

  • You cannot bind an occupied private IPv4 address, an occupied private IPv6 address, or an occupied public IPv6 address to the load balancer.

Constraints

There are some constraints when you create a load balancer:

  • vpc_id, vip_subnet_cidr_id, and ipv6_vip_virsubnet_id cannot be left blank at the same time.

  • ip_target_enable specifies whether to enable cross-VPC backend. If you have a load balancer with this function enabled, you can add servers in a VPC connected through a VPC peering connection, in a VPC connected through a cloud connection, or in an on-premises data center at the other end of a Direct Connect or VPN connection, by using server IP addresses.

  • admin_state_up must be set to true.

  • provider must be set to vlb.

  • elb_virsubnet_ids indicates the subnets that support IPv4/IPv6 dual stack or only IPv4 subnets. If only IPv4 subnets are supported, ipv6_vip_virsubnet_id must be left blank.

  • If you bind an EIP to the load balancer during creation, you cannot unbind it from the load balancer by calling the API after the load balancer is created. Instead, you can unbind the EIP only on the ELB console. Locate the load balancer in the load balancer list and click More > Unbind EIP in the Operation column.

  • publicip_ids and publicip cannot be specified at the same time. Set either publicip_ids to bind an existing EIP to the load balancer, or publicip to bind a new EIP to the load balancer, or neither of them.

  • If you want to add the load balancer to a shared bandwidth, you must specify the ID of the shared bandwidth. If you want the load balancer to use a new dedicated bandwidth, charge_mode, share_type, and size are required.

  • Dedicated load balancers are supported only in the eu-nl region.

URI

POST /v3/{project_id}/elb/loadbalancers

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

Minimum: 1

Maximum: 255

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Shows authentication information.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

loadbalancer

Yes

CreateLoadBalancerOption object

Specifies the load balancer.

Table 4 CreateLoadBalancerOption

Parameter

Mandatory

Type

Description

name

No

String

Specifies the load balancer name.

Minimum: 0

Maximum: 255

description

No

String

Provides supplementary information about the load balancer.

Minimum: 0

Maximum: 255

vip_address

No

String

Specifies the virtual IP address bound to the load balancer. The IP address must be from the IPv4 subnet of the VPC where the load balancer works and IP address should not be occupied by other services.

Note:

  • If both vip_subnet_cidr_id and vip_address are specified, a load balancer with a private IPv4 address will be created, and the virtual IP address specified by vip_address is the private IP address of the load balancer.

  • If only vip_subnet_cidr_id is specified, a load balancer with a private IPv4 address will be created, and the system will automatically assign a virtual IP address to the load balancer.

vip_subnet_cidr_id

No

String

Specifies the ID of the IPv4 subnet where the load balancer works. You can query neutron_subnet_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

  • Both vip_subnet_cidr_id and vip_address are required if you want to create a load balancer with a private IPv4 address.

  • publicip and either vpc_id or vip_subnet_cidr_id are required if you want to create a load balancer with a new IPv4 EIP.

  • publicip_ids and either vpc_id or vip_subnet_cidr_id are required if you want to with a load balancer with an existing IPv4 EIP.

  • The subnet specified by vip_subnet_cidr_id must be in the VPC specified by vpc_id if you specify both vpc_id and vip_subnet_cidr_id.

ipv6_vip_virsubnet_id

No

String

Specifies the ID of the IPv6 subnet where the load balancer works. You can query id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

Note:

  • ipv6_vip_virsubnet_id is required if you want to create a load balancer with a private IPv6 address.

  • Both ipv6_vip_virsubnet_id and ipv6_bandwidth are required if you want to create a load balancer with a public IPv6 address.

  • The subnet specified by ipv6_vip_virsubnet_id must be in the VPC specified by vpc_id if you specify both ipv6_vip_virsubnet_id and vpc_id.

  • IPv6 must be enabled for the subnet where the load balancer works.

provider

No

String

Specifies the provider of the load balancer. The value can only be vlb.

l4_flavor_id

No

String

Specifies the ID of the Layer-4 flavor.

Specify either l4_flavor_id or l7_flavor_id or both l4_flavor_id and l7_flavor_id when you create a load balancer.

The value can only be l4_flavor.elb.shared.

project_id

No

String

Specifies the project ID.

guaranteed

No

Boolean

Specifies whether the load balancer is a dedicated load balancer. The value can only be true. If the value is set to false, 400 Bad Request will be returned.

This parameter is unsupported. Please do not use it.

Default: true

vpc_id

No

String

Specifies the ID of the VPC where the load balancer works. You can query id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/vpcs).

  • The subnet specified by vip_subnet_cidr_id must be in the VPC specified by vpc_id if you specify both vip_subnet_cidr_id and vpc_id.

  • The subnet specified by ipv6_vip_virsubnet_id must be in the VPC specified by vpc_id if you specify both ipv6_vip_virsubnet_id and vpc_id.

availability_zone_list

Yes

Array of strings

Specifies the list of AZs where the load balancer can be created. You can query the AZs by calling the API (GET https://{ELB_Endpoint}/v3/{project_id}/elb/availability-zones). Select one or more AZs in the same set.

enterprise_project_id

No

String

Specifies the enterprise project ID. The value cannot be "", "0", or the ID of an enterprise project that does not exist. If this parameter is not passed during resource creation, the resource belongs to the default enterprise project.

This parameter is unsupported. Please do not use it.

tags

No

Array of Tag objects

Lists the tags added to the load balancer. Example: "tags":[{"key":"my_tag","value":"my_tag_value"}]

admin_state_up

No

Boolean

Specifies the administrative status of the load balancer. The value can only be true.

This parameter is unsupported. Please do not use it.

Default: true

l7_flavor_id

No

String

Specifies the ID of the Layer-7 flavor.

Specify either l4_flavor_id or l7_flavor_id or both l4_flavor_id and l7_flavor_id when you create a load balancer.

The value can only be l7_flavor.elb.shared

Minimum: 1

Maximum: 255

billing_info

No

String

Provides billing information about the load balancer.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 1024

ipv6_bandwidth

No

BandwidthRef object

Specifies the ID of the bandwidth. This parameter is available only when you create or update a load balancer that has an IPv6 address bound.

If you use a new IPv6 address and specify a shared bandwidth, the IPv6 address will be added to the shared bandwidth.

publicip_ids

No

Array of strings

Specifies the ID of the EIP the system will automatically assign and bind to the load balancer during load balancer creation. Currently, only the first EIP will be bound to the load balancer although multiple EIP IDs can be set.

publicip

No

CreateLoadBalancerPublicIpOption object

Provides information about the new IPv4 EIP that will be bound to the load balancer during load balancer creation.

elb_virsubnet_ids

No

Array of strings

Lists the IDs of subnets on the downstream plane. You can query parameter id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets).

If there is more than one subnet, the first subnet in the list will be used.

The subnets must be in the VPC where the load balancer works.

ip_target_enable

No

Boolean

Specifies whether to enable cross-VPC backend.

If you enable this function, you can add servers in a VPC connected through a VPC peering connection, in a VPC connected through a cloud connection, or in an on-premises data center at the other end of a Direct Connect or VPN connection, by using their IP addresses.

Table 5 Tag

Parameter

Mandatory

Type

Description

key

No

String

Specifies the tag key.

value

No

String

Specifies the tag value.

Table 6 BandwidthRef

Parameter

Mandatory

Type

Description

id

Yes

String

Specifies the shared bandwidth ID.

Table 7 CreateLoadBalancerPublicIpOption

Parameter

Mandatory

Type

Description

ip_version

No

Integer

Specifies the IP address version. The value can be 4 (IPv4) or 6 (IPv6).

Default: 4

network_type

Yes

String

Specifies the EIP type. The value can be 5_bgp (default) and 5_mailbgp.

Note

In eu-ch2, the value can only be 5_gray.

Minimum: 1

Maximum: 36

billing_info

No

String

Provides billing information about the IPv4 EIP. If billing_info is not left blank, the IPv4 EIP is billed on a yearly/monthly basis.

Minimum: 1

Maximum: 1024

description

No

String

Provides supplementary information about the IPv4 EIP.

Minimum: 1

Maximum: 255

bandwidth

Yes

CreateLoadBalancerBandwidthOption object

Provides supplementary information about the bandwidth.

Table 8 CreateLoadBalancerBandwidthOption

Parameter

Mandatory

Type

Description

name

No

String

Specifies the bandwidth name.

Minimum: 1

Maximum: 64

size

No

Integer

Specifies the bandwidth range.

The default range is 1 Mbit/s to 2,000 Mbit/s. (The specific range may vary depending on the configuration in each region. You can see the available bandwidth range on the management console.)

Note:

The minimum increment for bandwidth adjustment varies depending on the bandwidth range. The following are the details:

  • The minimum increment is 1 Mbit/s if the bandwidth range is from 0 Mbit/s to 300 Mbit/s.

  • The minimum increment is 50 Mbit/s if the bandwidth range is from 300 Mbit/s to 1,000 Mbit/s.

  • The minimum increment is 500 Mbit/s if the bandwidth is greater than 1,000 Mbit/s.

This parameter is mandatory if id is set to null.

Minimum: 0

Maximum: 99999

charge_mode

No

String

Specifies how the bandwidth used by the EIP is billed.

Currently, the bandwidth can be billed only by traffic.

This parameter is mandatory if id is set to null.

share_type

No

String

Specifies the bandwidth type.

The value options are as follows:

  • PER: indicates dedicated bandwidth.

  • WHOLE: indicates shared bandwidth.

This parameter is mandatory if id is set to null. It will be ignored if the value of id is not null.

billing_info

No

String

Provides billing information about the EIP. If this parameter is not left blank, the bandwidth is billed on a yearly/monthly basis.

Minimum: 1

Maximum: 1024

id

No

String

Specifies the ID of the shared bandwidth. You can add a load balancer to a shared bandwidth by specifying its ID.

If you have specified an ID, you do not need to pass other parameters. Even if you pass other parameters, the system will automatically ignore these parameters.

Response Parameters

Status code: 201

Table 9 Response body parameters

Parameter

Type

Description

loadbalancer

LoadBalancer object

Specifies the load balancer.

request_id

String

Specifies the request ID. The value is automatically generated.

Table 10 LoadBalancer

Parameter

Type

Description

id

String

Specifies the load balancer ID.

Default: Automatically generated

description

String

Provides supplementary information about the load balancer.

Minimum: 1

Maximum: 255

provisioning_status

String

Specifies the provisioning status of the load balancer. The value can only be ACTIVE.

admin_state_up

Boolean

Specifies the administrative status of the load balancer. The value can only be true.

This parameter is unsupported. Please do not use it.

Default: true

provider

String

Specifies the provider of the load balancer. The value can only be vlb.

Default: vlb

pools

Array of PoolRef objects

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

listeners

Array of ListenerRef objects

Lists the IDs of listeners added to the load balancer.

operating_status

String

Specifies the operating status of the load balancer. The value can only be ONLINE.

Minimum: 1

Maximum: 16

vip_address

String

Specifies the private IPv4 address bound to the load balancer.

Minimum: 1

Maximum: 64

vip_subnet_cidr_id

String

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

Minimum: 1

Maximum: 36

name

String

Specifies the name of the load balancer.

Minimum: 1

Maximum: 255

project_id

String

Specifies the project ID of the load balancer.

Minimum: 1

Maximum: 32

vip_port_id

String

Specifies the ID of the port bound to the virtual IP address (the value of vip_address) of the load balancer.

When you create a load balancer, the system automatically creates a port for the load balancer and associates the port with a default security group. However, security group rules containing the port will not affect traffic to and from the load balancer.

tags

Array of Tag objects

Lists the tags added to the load balancer.

created_at

String

Specifies the time when the load balancer was created.

Minimum: 1

Maximum: 20

updated_at

String

Specifies the time when the load balancer was updated.

Minimum: 1

Maximum: 20

guaranteed

Boolean

Specifies whether the load balancer is a dedicated load balancer.

The value can be true or false. true indicates a dedicated load balancer, and false indicates a shared load balancer. When dedicated load balancers are launched in the eu-de region, either true or false will be returned when you use the API to query or update a load balancer.

This parameter is unsupported. Please do not use it.

Default: true

vpc_id

String

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

eips

Array of EipInfo objects

Specifies the EIP bound to the load balancer.

ipv6_vip_address

String

Specifies the IPv6 address bound to the load balancer.

Default: None

Minimum: 1

Maximum: 64

ipv6_vip_virsubnet_id

String

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

ipv6_vip_port_id

String

Specifies the ID of the port bound to the IPv6 address.

availability_zone_list

Array of strings

Specifies the list of AZs where the load balancer is created.

enterprise_project_id

String

Specifies the enterprise project ID.

If this parameter is not passed during resource creation, the resource belongs to the default enterprise project.

This parameter is unsupported. Please do not use it.

Default: 0

billing_info

String

Provides billing information about the load balancer.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 1024

l4_flavor_id

String

Specifies the Layer-4 flavor.

Minimum: 1

Maximum: 255

l4_scale_flavor_id

String

Specifies the reserved Layer 4 flavor. This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 255

l7_flavor_id

String

Specifies the Layer-7 flavor.

Minimum: 1

Maximum: 255

l7_scale_flavor_id

String

Specifies the reserved Layer 7 flavor. This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 255

publicips

Array of PublicIpInfo objects

Specifies the EIP bound to the load balancer.

elb_virsubnet_ids

Array of strings

Specifies the ID of the subnet on the downstream plane. The ports used by the load balancer dynamically occupy IP addresses in the subnet.

elb_virsubnet_type

String

Specifies the type of the subnet on the downstream plane.

  • ipv4: IPv4 subnets

  • dualstack: subnets that support IPv4/IPv6 dual stack

ip_target_enable

Boolean

Specifies whether to enable cross-VPC backend.

Default: false

frozen_scene

String

Specifies the scenario where the load balancer is frozen. Use commas to separate multiple scenarios.

If the value is ARREAR, the load balancer is frozen because your account is in arrears.

ipv6_bandwidth

BandwidthRef object

Specifies the ID of the bandwidth. This parameter is available only when you create or update a load balancer that has an IPv6 address bound.

If you use a new IPv6 address and specify a shared bandwidth, the IPv6 address will be added to the shared bandwidth.

Table 11 PoolRef

Parameter

Type

Description

id

String

Specifies the ID of the backend server group.

Table 12 ListenerRef

Parameter

Type

Description

id

String

Specifies the listener ID.

Table 13 Tag

Parameter

Type

Description

key

String

Specifies the tag key.

value

String

Specifies the tag value.

Table 14 EipInfo

Parameter

Type

Description

eip_id

String

Specifies the EIP ID.

eip_address

String

Specifies the specific IP address.

ip_version

Integer

Specifies the IP version. 4 indicates IPv4, and 6 indicates IPv6.

Table 15 PublicIpInfo

Parameter

Type

Description

publicip_id

String

Specifies the EIP ID.

publicip_address

String

Specifies the IP address.

ip_version

Integer

Specifies the IP version. The value can be 4 (IPv4) or 6 (IPv6).

Table 16 BandwidthRef

Parameter

Type

Description

id

String

Specifies the shared bandwidth ID.

Example Requests

Creating a load balancer with an IPv4 EIP

POST https://{ELB_Endponit}/v3/060576782980d5762f9ec014dd2f1148/elb/loadbalancers

{
  "loadbalancer" : {
    "vpc_id" : "e5a892ff-3c33-44ef-ada5-b713eb1f7a8b",
    "availability_zone_list" : [ "br-iaas-odin1a" ],
    "admin_state_up" : true,
    "vip_subnet_cidr_id" : "1800b6b8-a69f-4719-813d-24d62aaf32bd",
    "elb_virsubnet_ids" : [ "1fe8c0a8-d648-4294-8ea5-4d7f0c700e69" ],
    "name" : "elb-ipv4-public",
    "publicip" : {
      "network_type" : "5_bgp",
      "bandwidth" : {
        "size" : 2,
        "share_type" : "PER",
        "charge_mode" : "traffic",
        "name" : "elb_eip_traffic"
      }
    }
  }
}

Example Responses

Status code: 201

Successful request.

{
  "request_id" : "86bb342be098113734389bffcf593607",
  "loadbalancer" : {
    "id" : "badd5a4b-14cf-4319-ac91-4182a80dee9a",
    "project_id" : "060576782980d5762f9ec014dd2f1148",
    "name" : "elb-ipv4-public",
    "description" : "",
    "vip_port_id" : "265c13fb-49a9-4f51-b848-7f0cced0aef0",
    "vip_address" : "192.168.0.151",
    "admin_state_up" : true,
    "provisioning_status" : "ACTIVE",
    "operating_status" : "ONLINE",
    "listeners" : [ ],
    "pools" : [ ],
    "tags" : [ ],
    "provider" : "vlb",
    "created_at" : "2021-03-29T02:44:47Z",
    "updated_at" : "2021-03-29T02:44:47Z",
    "vpc_id" : "e5a892ff-3c33-44ef-ada5-b713eb1f7a8b",
    "enterprise_project_id" : "0",
    "availability_zone_list" : [ "br-iaas-odin1a" ],
    "ipv6_vip_address" : null,
    "ipv6_vip_virsubnet_id" : null,
    "ipv6_vip_port_id" : null,
    "ipv6_bandwidth" : null,
    "publicips" : [ {
      "publicip_id" : "448d497a-8f65-4c17-b2b2-f21279446e00",
      "publicip_address" : "10.246.170.154",
      "ip_version" : 4
    } ],
    "elb_virsubnet_ids" : [ "4df3e391-5ebf-4300-b614-cf5a4e793666" ],
    "elb_virsubnet_type" : "dualstack",
    "ip_target_enable" : false,
    "frozen_scene" : null,
    "eips" : [ {
      "eip_id" : "448d497a-8f65-4c17-b2b2-f21279446e00",
      "eip_address" : "10.246.170.154",
      "ip_version" : 4
    } ],
    "guaranteed" : true,
    "billing_info" : null,
    "l4_flavor_id" : "e5acacda-f861-404e-9871-df480c49d185",
    "l4_scale_flavor_id" : null,
    "l7_flavor_id" : "2f124f60-980a-42f3-b201-35461df1b936",
    "l7_scale_flavor_id" : null,
    "vip_subnet_cidr_id" : "1800b6b8-a69f-4719-813d-24d62aaf32bd"
  }
}

Status Codes

Status Code

Description

201

Successful request.

Error Codes

See Error Codes.