Creating a Load Balancer
Scenarios
Assume that you have created a VPC and several ECSs on the cloud platform. To ensure high performance and availability of ECSs, a load balancer is required to distribute requests to different backend ECSs.
This section describes how to invoke the API to create a load balancer.
The validity period of a token obtained from IAM is 24 hours. If you want to use a token for authentication, cache it to avoid frequently calling the IAM API.
Involved APIs
If you use a token for authentication, you must obtain the token and add X-Auth-Token to the request header of the ELB API when making an API call.
- IAM API used to obtain the token
- ELB API used to create a load balancer
Procedure
- Obtain the token by referring to Authentication.
- Send POST https://ELB endpoint/v2.0/lbaas/loadbalancers.
- Add X-Auth-Token to the request header.
- Specify the following parameters in the request body:
{ "loadbalancer": { "name": "loadbalancer1", //Load balancer name "description": "simple lb", //Load balancer description "vip_subnet_id": "58077bdb-d470-424b-8c45-2e3c65060a5b", //ID of the IPv4 subnet where the load balancer works "vip_address": "10.0.0.4" //IP address of the load balancer } }
If the request is successful, the response body is returned.
If the request fails, an error code and error information are returned. For details, see Status Codes.
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