API
Load Balancers
Create load balancer

Create a Load Balancer

  • Name
    post
    Type
    /v1/load_balancers
    Description

    Send a POST request to create a load balancer.

Request

Load balancer Attributes

Required

  • Name
    name
    Type
    string
    Description

    Human readable name for the load balancer.

  • Name
    rules
    Type
    array
    Description

    Forwarding rules for the load balancer.

  • Name
    region
    Type
    string
    Description

    The region name where the load balancer is located.

  • Name
    health
    Type
    array
    Description

    Health check settings for the load balancer.

  • Name
    algorithm
    Type
    boolean
    Description

    The load balancing algorithm used to determine which backend Stacklet will be selected by the client. It must be either round_robin or least_connections.

Optional

  • Name
    project_uuid
    Type
    string
    Description

    The project universal unique identifier where the load balancer will be placed. If the user didn't provide the UUID, the system will replace the load balancer in the user default project.

  • Name
    stacklet_ids
    Type
    array
    Description

    The Stacklets ids where the load balancer will be assigned.

  • Name
    sticky_sessions
    Type
    object
    Description

    Sticky sessions settings for the load balancer.

  • Name
    redirect_http_to_https
    Type
    boolean
    Description

    A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443.

Sticky Sessions Attributes

Required

The request may also contain sticky_sessions settings. Sticky sessions will not be configured if omitted. A load balancer's sticky_sessions attribute is made up of an array of object with the following attributes:

  • Name
    name
    Type
    string
    Description

    The name of the load balancer cookie sent to the client. This attribute is only returned when using "cookies" for the sticky sessions type.

  • Name
    ttl
    Type
    string
    Description

    The number of seconds until the load balancer cookie expires. This attribute is only returned when using "cookies" for the sticky sessions type.

Health Attributes

The request must contain health check settings. The load balancer's health attribute is made up of an array of objects with the following attributes:

Required

  • Name
    rise
    Type
    integer
    Description

    The number of times a health check must pass for a backend Stacklet to be marked "healthy" and be re-added to the pool.

  • Name
    fall
    Type
    integer
    Description

    The number of times a health check must fail for a backend Stacklet to be marked "unhealthy" and be removed from the pool.

  • Name
    interval
    Type
    integer
    Description

    The number of seconds between two consecutive health checks.

  • Name
    protocol
    Type
    string
    Description

    The protocol which the health checks use in order to sent connection attempt to the backend Stacklets. The possible values are: "http" or "tcp".

Optional

  • Name
    path
    Type
    string
    Description

    The path on the backend Stacklets to which the load balancer instance will send a request.

  • Name
    port
    Type
    integer
    Description

    The port on the backend Stacklets on which the health check will attempt a connection.

Rules Attributes

The request must contain at least one forwarding rule. The load balancer's rules attribute is made up of an array of objects with the following attributes:

Required

  • Name
    protocol
    Type
    string
    Description

    The protocol which the health checks use in order to sent connection attempt to the backend Stacklets. The possible values are: "http", "https", "http2", or "tcp".

  • Name
    source_port
    Type
    integer
    Description

    The port on which the load balancer instance will listen.

  • Name
    target_port
    Type
    integer
    Description

    The port on the backend Stacklets to which the load balancer will send traffic to.

Optional

  • Name
    certificate_id
    Type
    integer
    Description

    The ID of the TLS certificate used for SSL termination.

  • Name
    tls_passthrough
    Type
    boolean
    Description

    A value indicating whether the SSL encrypted traffic will be passed through to the backend Stacklets. Default value for this attribute is false.

Example

curl -X POST "https://api.simplystack.com/v1/load_balancers" \
  -H "Content-Type: application/json" \
  -H "Authorization: Token d359ad9cc9422b5ff07aede0cd2707da4ff82be0" \
  -d '{"name": "lb01","algorithm": "round_robin","region": "fra","rules": [{"protocol": "http","source_port": 80,"target_port": 80,"certificate_id": null,"tls_passthrough": false},{"protocol": "https","source_port": 443,"target_port": 443,"certificate_id": 7,"tls_passthrough": false}],"health": {"protocol": "http","port": 80,"path": "/","interval": 10,"rise": 3,"fall": 3},"redirect_http_to_https": false,"stacklet_id": [1,2]}'
 

Response

JSON object with key named load_balancer which is an array of the following attributes for the load_balancers object:

Load Balancer Attributes

See load balancer model.

Health Attibutes

When the health object is returned, health checks are used to tell if a Stacklet is responding and should receive traffic. The load balancer will automatically stop sending traffic to the unresponsive Stacklets. The User may specify the protocol, port, and path for a health check as well as additional setting such as the check interval and response timeout. The following are the returned attributes:

See health model.

Rules Attributes

When the rules object is returned, the Forwarding rules determine how traffic will be routed from the load balancer to the Stacklets assigned to it. They can be used to configure the type of traffic (HTTP, HTTPS, or TCP) and to map ports on the load balancer to ports on the Stacklets. For SSL encrypted traffic, the user may also configure whether to use SSL termination at the load balancer (by specifying an SSL certificate) or to pass the encrypted traffic through to the Stacklet. The following are the returned attributes:

See health model.

Sticky Sessions Attributes

When sticky_sessions object is returned, that means sticky sessions are in use, follow up requests from the client will be sent to the same Stacklet as the original request. Both the name of the cookie and the TTL are configurable as follow:

See sticky sessions model.

Example

{
  "load_balancer": {
    "uuid": "21848c7e-0389-4fdf-95bf-7d4d58d62c22",
    "name": "lb01",
    "created_at": "2020-01-07T18:37:45.190194Z",
    "task": {
      "id": 1,
      "name": "create",
      "description": {
        "completed": "Load balanceer was created.",
        "progress": "Load balancer is creating."
      }
    },
    "region": {
      "available": true,
      "features": [
          "floating_ips"
      ],
      "name": "Frankfurt",
      "slug": "fra"
    },
    "ip": 192.168.1.17,
    "algorithm": "round_robin",
    "sticky_sessions": null,
    "rules": [
      {
        "protocol": "http",
        "source_port": 80,
        "target_port": 80,
        "certificate_id": null,
        "tls_passthrough": false
      },
      {
        "protocol": "https",
        "source_port": 443,
        "target_port": 443,
        "certificate_id": 7,
        "tls_passthrough": false
      }
    ],
    "health": {
      "protocol": "http",
      "port": 80,
      "path": "/",
      "interval": 10,
      "rise": 3,
      "fall": 3
    },
    "redirect_http_to_https": false,
    "stacklet_ids": [
      1,
      2
    ]
  }
}