• Elastic Load Balancing

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

Creating a Load Balancer

Function

This API is used to create a load balancer.

URI

POST /v1.0/{project_id}/elbaas/loadbalancers
Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID of the operator.

Request

  • Request parameters
    Table 2 Parameter description

    Parameter

    Mandatory

    Type

    Description

    name

    Yes

    String

    • Specifies the load balancer name.
    • The value is a string of 1 to 64 characters that consist of Chinese characters, letters, digits, underscores (_), and hyphens (-).

    description

    No

    String

    • Provides supplementary information about the load balancer.
    • The value is a string of 0 to 128 characters and cannot contain angle brackets (< and >).

    vpc_id

    Yes

    String

    Specifies the VPC ID.

    bandwidth

    No

    Integer

    • Specifies the bandwidth size. This parameter is mandatory when type is set to External.
    • The value ranges from 1 to 500.

      (The specific range may vary depending on the configuration in each region. You can see the bandwidth range of each region on the management console.)

    type

    Yes

    String

    • Specifies the network type of the load balancer.
    • The value is Internal or External.

    admin_state_up

    Yes

    Integer/Boolean

    • Specifies the administrative status of the load balancer.
    • Optional values:

      0 or false: indicates that the load balancer is stopped. Only tenants are allowed to enter these two values.

      1 or true: indicates that the load balancer is running properly.

      2 or false: indicates that the load balancer is frozen. Only tenants are allowed to enter these two values.

    vip_subnet_id

    No

    String

    Specifies the subnet ID of backend ECSs. This parameter is mandatory when type is set to Internal. Only IPv4 subnets can be specified.

    az

    No

    String

    Specifies the AZ where the load balancer works. This field is valid when type is set to Internal. If type is set to Internal and an AZ is specified, the specified AZ must support private network load balancers. Otherwise, an error message is returned.

    charge_mode

    No

    String

    • Specifies how a new elastic IP address (EIP) is billed. This is a reserved field. If the system supports charging by traffic and this field is specified, the EIP will be billed by traffic.
    • Specifies whether the EIP is billed by traffic or bandwidth size. If this parameter is left blank or incorrectly set, the EIP is billed by traffic by default.
    • The value is traffic.

    eip_type

    No

    String

    • This parameter is reserved.

    security_group_id

    No

    String

    • Specifies the security group ID.
    • The value is a string of 1 to 200 characters that consists of uppercase and lowercase letters, digits, and hyphens (-).
    • This parameter is mandatory if the value of type is Internal, while it is ignored when the value of type is External.

    vip_address

    No

    String

    • Specifies the IP address used by ELB for providing services. When type is set to External, the parameter value is the EIP. When type is set to Internal, the parameter value is the private network IP address.
    • You can select an existing EIP to create a public network load balancer. When this parameter is configured, parameters bandwidth, charge_mode, and eip_type are invalid.

    tenantId

    No

    String

    • Specifies the project ID.
    • This parameter is mandatory when type is set to Internal.
  • Example request 1
    {
        "name": "loadbalancer1",
        "description": "simple lb",
        "vpc_id": "f54a3ffd-7a55-4568-9e3d-f0ff2d46a107",
        "bandwidth": 200,
        "type": "External",
        "admin_state_up": true
    }
  • Example request 2
    {
        "name": "loadbalancer1",
        "description": "simple lb",
        "vpc_id": "f54a3ffd-7a55-4568-9e3d-f0ff2d46a107",
        "vip_address": "192.144.164.74",
        "type": "External",
        "admin_state_up": true
    }

Response

  • Response parameters
    Table 3 Parameter description

    Parameter

    Type

    Description

    uri

    String

    Specifies the URI returned by Combined API after the job for creating a load balancer is issued.

    job_id

    String

    Specifies the unique job ID in Combined API.

  • Example response
    {
        "uri": "/v1/73cd9140bec7427ab9952b4ed75924e0/jobs/4010b39b4fbb4645014fcfc8f2d178d1",
        "job_id": "4010b39b4fbb4645014fcfc8f2d178d1"
    }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 badRequest

    Request error.

    401 unauthorized

    Authentication failed.

    403 userDisabled

    You do not have the rights to perform the operation.

    404 Not Found

    The requested page does not exist.

    500 authFault

    System error.

    503 serviceUnavailable

    The service is unavailable.