Creating a Public Network Load Balancer
When an EIP is bound to a private network load balancer, the load balancer becomes a public network load balancer. Clients can access backend servers through this load balancer over Internet.
Apply for an EIP
API Format
Method |
URI |
Description |
---|---|---|
POST |
/v1/{tenant_id}/publicips |
Applies for an EIP. |
Procedure
- Set the request header.
Set the header in Postman and place the obtained token in the header.
- Under Body, set the request body.
- Enter the URL.
https://vpc.cn-east-2.myhuaweicloud.com/v1/0d0bf0e8fb564cc9abbe526dbdca9248/publicips
- Send the request. Set the POST request method and click Send to wait for response from the server.
{ "publicip": { "id": "73c079fc-357a-4d34-8ba1-818a9d9a2aa2", "status": "PENDING_CREATE", "type": "5_sbgp", "public_ip_address": "122.112.235.121", "tenant_id": "0d0bf0e8fb564cc9abbe526dbdca9248", "create_time": "2018-07-11 02:40:32", "bandwidth_size": 0, "enterprise_project_id": "0" } }
Note that the value of tenant_id in the response body is the project ID on the web console.
Sample Code
Request body in 2
{ "publicip": { "type": "5_sbgp" }, "bandwidth": { "name": "bandwidth_elb", "size": 1, "share_type": "PER", "charge_mode": "traffic" } }
For details about fields in the request body and their formats, see the Virtual Private Cloud API Reference.
Bind the EIP
API Format
Method |
URI |
Description |
---|---|---|
PUT |
/v1/{tenant_id}/publicips/{publicip_id} |
Binds the EIP to a load balancer. |
Procedure
- Set the request header.
Set the header in Postman and place the obtained token in the header.
- Under Body, set the request body.
The value of port_id can be obtained by calling the VPC API. The request is as follows:
GET https://vpc.cn-north-1.myhuaweicloud.com/v2.0/ports?network_id=Network ID&fixed_ips=ip_address=Private IP address of the load balancer
Choose Network > Virtual Private Cloud, click the target VPC name, and obtain the network ID and private IP address of the load balancer on the subnet details page.
- Enter the URL.
https://vpc.cn-east-2.myhuaweicloud.com/v1/{{project_id}}/publicips/{{eip_id}}
eip_id is the ID returned when the EIP is assigned in Apply for an EIP.
- Send the request. Set the PUT request method and click Send to wait for response from the server.
{ "publicip": { "id": "73c079fc-357a-4d34-8ba1-818a9d9a2aa2", "status": "ACTIVE", "type": "5_sbgp", "port_id": "d2c5a9fc-6a91-4a2d-8aac-e8e8ca6da727", "public_ip_address": "122.112.235.121", "private_ip_address": "192.168.0.160", "tenant_id": "0d0bf0e8fb564cc9abbe526dbdca9248", "create_time": "2018-07-11 02:40:32", "bandwidth_size": 1 } }
Sample Code
Request body in 2
{ "publicip": { "port_id": "d2c5a9fc-6a91-4a2d-8aac-e8e8ca6da727" } }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot