Create Load Balancer

(Difference between revisions)
Jump to: navigation, search
m (1 revision: Release 95)
(create a LB)
Line 1: Line 1:
A Load balancer distributes traffic among different nodes. You have the ability to configure your load balancer as required. A Load balancer has a single public-facing virtual IP Address and port on one side and nodes on the other side: traffic into the virtual IP may be delivered to the IP Address of any of the contained nodes. The reverse mapping occurs for outbound traffic. If you need to provide load balancing for more than one virtual IP address or more than one port on a single virtual IP address, you must create multiple load balancers. Note: a load balancer without a virtual IP address and at least two nodes is not useful
 
 
 
='''POST''' /accounts/''{accountId}''/loadbalancers=
 
='''POST''' /accounts/''{accountId}''/loadbalancers=
This operation will create a new load balancer.
+
This operation creates a new load balancer.
  
 
== Request ==
 
== Request ==
=== URI Parameters ===
+
<code>POST /accounts/''{accountId}''/loadbalancers</code>
 +
 
 +
=== Request Parameters ===
 
; accountId - ''string''
 
; accountId - ''string''
: The selected account Id.
+
: The selected account id.
  
 
=== Request Body ===
 
=== Request Body ===
 
  <nowiki>
 
  <nowiki>
{
+
{
 
     "region": "{regionTextKey}",
 
     "region": "{regionTextKey}",
     "displayName": "{lbName}",
+
     "displayName": "{lbName}"
    "port": {lbPort},
+
}</nowiki>
    "protocol": "{lBProtocol}",
+
    "virtualIp": "{lbVirtualIp}",
+
    "algorithm": "{ROUND_ROBIN or SOURCE_IP}",
+
    "timeout": {timeout},
+
    "nodes" : [
+
                  {
+
                      "serverRef": "{serverRefURL}",
+
                      "port" : {port1}
+
                  },
+
                  {
+
                      "serverRef": "{serverRefURL}",
+
                      "port" : {port2}
+
                  }
+
              ]
+
    "sessionPersistence" : {
+
                      "persistenceType":"HTTP_COOKIE"
+
              },         
+
    "healthMonitor" :      {
+
              "protocol":"{hcProtocol}",
+
              "interval": {hcInterval},
+
              "port": {hcPort},
+
              "uri": {uri},
+
              "attemptsBeforeDeactivation": {hcAttemptsBeforeDeactivation},
+
              "attemptsBeforeActivation" : {hcAttemptsBeforeActivation}
+
          },
+
}</nowiki>
+
  
 
==== Parameters ====
 
==== Parameters ====
Line 49: Line 23:
 
: Display name for this load balancer.
 
: Display name for this load balancer.
  
; port - ''integer''
+
== Response ==
: range 1 ~ 65535
+
: the port number to switch traffic for.
+
 
+
; protocol - ''string''
+
: either 'TCP' or 'HTTP'
+
 
+
; virtualIp - ''string''
+
: if this is omitted, LB will allocate a new virtual ip to this account
+
: this virtual ip that must be owned by this account in advance or available one
+
: IPv4 or IPv6 possible
+
 
+
; algorithm - ''string''
+
: LB distribution algorithm
+
: either 'ROUND_ROBIN' or 'SOURCE_IP'
+
 
+
; timeout - ''integer''
+
: node-check and connect timeout
+
 
+
; nodes
+
: list of node
+
: should include at least one node when creating a LB
+
 
+
; nodes.serverRef - ''string''
+
: the URL ref of a node
+
  
; nodes.port - ''integer''
 
: range 1 ~ 65535
 
: the ports on node that LB forward traffic to
 
 
; nodes.condition - ''string''
 
: the condition of a node, ENABLED or DISABLED
 
 
== Response ==
 
 
=== Response Codes ===
 
=== Response Codes ===
  
Line 88: Line 30:
  
 
; 400 Bad Request
 
; 400 Bad Request
 +
: The request has wrong data
  
 
; 401 Unauthorized
 
; 401 Unauthorized
Line 100: Line 43:
  
 
== Examples ==
 
== Examples ==
 +
 +
=== create a LB ===
  
 
'''Request'''
 
'''Request'''
Line 105: Line 50:
 
POST /accounts/{accountId}/loadbalancers
 
POST /accounts/{accountId}/loadbalancers
 
Content-Type: application/json; Charset=UTF-8
 
Content-Type: application/json; Charset=UTF-8
Authorization: Base64-encoded username & password string
+
Authorization: Basic {Base64-encoded username & password string}
  
 
{
 
{
 
     "region": "AUSTIN",
 
     "region": "AUSTIN",
 
     "displayName" : "Test Load Balancer",
 
     "displayName" : "Test Load Balancer",
    "port": 80,
 
    "protocol": "HTTP",
 
    "algorithm": "ROUND_ROBIN",
 
    "timeout": 30,
 
    "nodes": [
 
        {
 
            "serverRef": "http://{hostname}/accounts/{accountId}/flexcloud/servers/{serverId-1}",
 
            "port": 80
 
        }, {
 
            "serverRef": "http://{hostname}/accounts/{accountId}/flexcloud/servers/{serverId-2}",
 
            "port": 80
 
        }
 
    ]       
 
 
}
 
}
 
</pre>
 
</pre>
Line 130: Line 62:
 
201 Created
 
201 Created
 
Content-Type: application/json; charset=UTF-8
 
Content-Type: application/json; charset=UTF-8
Location : </nowiki>{{APIBaseURL}}<nowiki>/account/{accountId}/loadbalancer/{lbId}
+
Location : http://{api-server}/account/{accountId}/loadbalancers/{newLbId}
 +
</pre>
 +
 
 +
=== Failure while trying to make unauthorized access ===
 +
 
 +
'''Request'''
 +
<pre>
 +
POST /accounts/{accountId}/loadbalancers
 +
Content-Type:application/json
 +
Charset=UTF-8
 +
Authorization: Basic {Base64-encoded username & password string}
 +
</pre>
 +
 
 +
'''Response'''
 +
<pre>
 +
HTTP/1.1 401 Unauthorized
 +
</pre>
 +
 
 +
=== Failure while trying to pass invalid account number ===
 +
'''Request'''
 +
<pre>
 +
POST /accounts/fake/loadbalancers
 +
Content-Type:application/json
 +
Charset=UTF-8
 +
Authorization: Basic {wrong credential}
 +
</pre>
 +
 
 +
'''Response'''
 +
<pre>
 +
HTTP/1.1 404 Not Found
 +
 
 +
{
 +
    "itemNotFound" : {
 +
        "message": "Resource not found",
 +
        "code": 404,
 +
        "details": "",
 +
        "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf"
 +
    }
 +
}
 
</pre>
 
</pre>
  
{{disqus}}
 
 
[[Category:Hostway API]]
 
[[Category:Hostway API]]
 
[[Category:Load Balancer API]]
 
[[Category:Load Balancer API]]

Revision as of 19:17, 23 January 2015

Contents

POST /accounts/{accountId}/loadbalancers

This operation creates a new load balancer.

Request

POST /accounts/{accountId}/loadbalancers

Request Parameters

accountId - string
The selected account id.

Request Body

{
    "region": "{regionTextKey}",
    "displayName": "{lbName}"
}

Parameters

region - string
region TextKey where LB will be created
displayName - string
Display name for this load balancer.

Response

Response Codes

201 Created
400 Bad Request
The request has wrong data
401 Unauthorized
This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.
409 Conflict
The resource already exists. (there is already a load balancer with that name or a load balancer already bound to the virtualIp/port combination specified)

Response Headers

Location
Returned with successful 201 response. Contains the new LB URI. The client must use this URI for all subsequent operations with the LB.

Examples

create a LB

Request

POST /accounts/{accountId}/loadbalancers
Content-Type: application/json; Charset=UTF-8
Authorization: Basic {Base64-encoded username & password string}

{
    "region": "AUSTIN",
    "displayName" : "Test Load Balancer",
}

Response

201 Created
Content-Type: application/json; charset=UTF-8
Location : http://{api-server}/account/{accountId}/loadbalancers/{newLbId}

Failure while trying to make unauthorized access

Request

POST /accounts/{accountId}/loadbalancers
Content-Type:application/json
Charset=UTF-8
Authorization: Basic {Base64-encoded username & password string}

Response

HTTP/1.1 401 Unauthorized

Failure while trying to pass invalid account number

Request

POST /accounts/fake/loadbalancers
Content-Type:application/json
Charset=UTF-8
Authorization: Basic {wrong credential}

Response

HTTP/1.1 404 Not Found

{
    "itemNotFound" : {
        "message": "Resource not found", 
        "code": 404, 
        "details": "",
        "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf"
    }
}
Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox