curl --request POST \
--url https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "new_load_balancer",
"flavor": "lb1-1-2",
"floating_ip": {
"source": "existing"
},
"listeners": [
{
"name": "my_listener",
"protocol_port": 80,
"allowed_cidrs": [
"10.0.0.0/8"
],
"connection_limit": 100000,
"insert_x_forwarded": false,
"pools": [
{
"name": "pool_name",
"ca_secret_id": "<string>",
"crl_secret_id": "<string>",
"healthmonitor": {
"delay": 10,
"domain_name": "example.com",
"http_method": "GET",
"http_version": "1.1",
"max_retries": 3,
"max_retries_down": 3,
"timeout": 5,
"type": "HTTP",
"url_path": "/"
},
"members": [
{
"address": "192.168.1.101",
"instance_id": "a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9",
"protocol_port": 8000,
"weight": 2
},
{
"address": "192.168.1.102",
"instance_id": "169942e0-9b53-42df-95ef-1a8b6525c2bd",
"protocol_port": 8000,
"weight": 4
}
],
"secret_id": "<string>",
"session_persistence": {
"cookie_name": "cookie_name",
"type": "APP_COOKIE"
},
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": 43200000
}
],
"secret_id": "f2e734d0-fa2b-42c2-ad33-4c6db5101e00",
"sni_secret_id": [
"f2e734d0-fa2b-42c2-ad33-4c6db5101e00",
"eb121225-7ded-4ff3-ae1f-599e145dd7cb"
],
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": null,
"user_list": [
{
"encrypted_password": "$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5",
"username": "admin"
}
]
}
],
"logging": {
"destination_region_id": 1,
"enabled": true,
"retention_policy": {
"period": 45
},
"topic_name": "my-log-name"
},
"preferred_connectivity": "L2",
"tags": {},
"vip_network_id": "ac307687-31a4-4a11-a949-6bea1b2878f5",
"vip_port_id": "ff83e13a-b256-4be2-ba5d-028d3f0ab450",
"vip_subnet_id": "4e7802d3-5023-44b8-b298-7726558fddf4"
}
'import requests
url = "https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}"
payload = {
"name": "new_load_balancer",
"flavor": "lb1-1-2",
"floating_ip": { "source": "existing" },
"listeners": [
{
"name": "my_listener",
"protocol_port": 80,
"allowed_cidrs": ["10.0.0.0/8"],
"connection_limit": 100000,
"insert_x_forwarded": False,
"pools": [
{
"name": "pool_name",
"ca_secret_id": "<string>",
"crl_secret_id": "<string>",
"healthmonitor": {
"delay": 10,
"domain_name": "example.com",
"http_method": "GET",
"http_version": "1.1",
"max_retries": 3,
"max_retries_down": 3,
"timeout": 5,
"type": "HTTP",
"url_path": "/"
},
"members": [
{
"address": "192.168.1.101",
"instance_id": "a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9",
"protocol_port": 8000,
"weight": 2
},
{
"address": "192.168.1.102",
"instance_id": "169942e0-9b53-42df-95ef-1a8b6525c2bd",
"protocol_port": 8000,
"weight": 4
}
],
"secret_id": "<string>",
"session_persistence": {
"cookie_name": "cookie_name",
"type": "APP_COOKIE"
},
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": 43200000
}
],
"secret_id": "f2e734d0-fa2b-42c2-ad33-4c6db5101e00",
"sni_secret_id": ["f2e734d0-fa2b-42c2-ad33-4c6db5101e00", "eb121225-7ded-4ff3-ae1f-599e145dd7cb"],
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": None,
"user_list": [
{
"encrypted_password": "$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5",
"username": "admin"
}
]
}
],
"logging": {
"destination_region_id": 1,
"enabled": True,
"retention_policy": { "period": 45 },
"topic_name": "my-log-name"
},
"preferred_connectivity": "L2",
"tags": {},
"vip_network_id": "ac307687-31a4-4a11-a949-6bea1b2878f5",
"vip_port_id": "ff83e13a-b256-4be2-ba5d-028d3f0ab450",
"vip_subnet_id": "4e7802d3-5023-44b8-b298-7726558fddf4"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'new_load_balancer',
flavor: 'lb1-1-2',
floating_ip: {source: 'existing'},
listeners: [
{
name: 'my_listener',
protocol_port: 80,
allowed_cidrs: ['10.0.0.0/8'],
connection_limit: 100000,
insert_x_forwarded: false,
pools: [
{
name: 'pool_name',
ca_secret_id: '<string>',
crl_secret_id: '<string>',
healthmonitor: {
delay: 10,
domain_name: 'example.com',
http_method: 'GET',
http_version: '1.1',
max_retries: 3,
max_retries_down: 3,
timeout: 5,
type: 'HTTP',
url_path: '/'
},
members: [
{
address: '192.168.1.101',
instance_id: 'a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9',
protocol_port: 8000,
weight: 2
},
{
address: '192.168.1.102',
instance_id: '169942e0-9b53-42df-95ef-1a8b6525c2bd',
protocol_port: 8000,
weight: 4
}
],
secret_id: '<string>',
session_persistence: {cookie_name: 'cookie_name', type: 'APP_COOKIE'},
timeout_client_data: 50000,
timeout_member_connect: 50000,
timeout_member_data: 43200000
}
],
secret_id: 'f2e734d0-fa2b-42c2-ad33-4c6db5101e00',
sni_secret_id: ['f2e734d0-fa2b-42c2-ad33-4c6db5101e00', 'eb121225-7ded-4ff3-ae1f-599e145dd7cb'],
timeout_client_data: 50000,
timeout_member_connect: 50000,
timeout_member_data: null,
user_list: [
{
encrypted_password: '$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5',
username: 'admin'
}
]
}
],
logging: {
destination_region_id: 1,
enabled: true,
retention_policy: {period: 45},
topic_name: 'my-log-name'
},
preferred_connectivity: 'L2',
tags: {},
vip_network_id: 'ac307687-31a4-4a11-a949-6bea1b2878f5',
vip_port_id: 'ff83e13a-b256-4be2-ba5d-028d3f0ab450',
vip_subnet_id: '4e7802d3-5023-44b8-b298-7726558fddf4'
})
};
fetch('https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'new_load_balancer',
'flavor' => 'lb1-1-2',
'floating_ip' => [
'source' => 'existing'
],
'listeners' => [
[
'name' => 'my_listener',
'protocol_port' => 80,
'allowed_cidrs' => [
'10.0.0.0/8'
],
'connection_limit' => 100000,
'insert_x_forwarded' => false,
'pools' => [
[
'name' => 'pool_name',
'ca_secret_id' => '<string>',
'crl_secret_id' => '<string>',
'healthmonitor' => [
'delay' => 10,
'domain_name' => 'example.com',
'http_method' => 'GET',
'http_version' => '1.1',
'max_retries' => 3,
'max_retries_down' => 3,
'timeout' => 5,
'type' => 'HTTP',
'url_path' => '/'
],
'members' => [
[
'address' => '192.168.1.101',
'instance_id' => 'a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9',
'protocol_port' => 8000,
'weight' => 2
],
[
'address' => '192.168.1.102',
'instance_id' => '169942e0-9b53-42df-95ef-1a8b6525c2bd',
'protocol_port' => 8000,
'weight' => 4
]
],
'secret_id' => '<string>',
'session_persistence' => [
'cookie_name' => 'cookie_name',
'type' => 'APP_COOKIE'
],
'timeout_client_data' => 50000,
'timeout_member_connect' => 50000,
'timeout_member_data' => 43200000
]
],
'secret_id' => 'f2e734d0-fa2b-42c2-ad33-4c6db5101e00',
'sni_secret_id' => [
'f2e734d0-fa2b-42c2-ad33-4c6db5101e00',
'eb121225-7ded-4ff3-ae1f-599e145dd7cb'
],
'timeout_client_data' => 50000,
'timeout_member_connect' => 50000,
'timeout_member_data' => null,
'user_list' => [
[
'encrypted_password' => '$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5',
'username' => 'admin'
]
]
]
],
'logging' => [
'destination_region_id' => 1,
'enabled' => true,
'retention_policy' => [
'period' => 45
],
'topic_name' => 'my-log-name'
],
'preferred_connectivity' => 'L2',
'tags' => [
],
'vip_network_id' => 'ac307687-31a4-4a11-a949-6bea1b2878f5',
'vip_port_id' => 'ff83e13a-b256-4be2-ba5d-028d3f0ab450',
'vip_subnet_id' => '4e7802d3-5023-44b8-b298-7726558fddf4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}"
payload := strings.NewReader("{\n \"name\": \"new_load_balancer\",\n \"flavor\": \"lb1-1-2\",\n \"floating_ip\": {\n \"source\": \"existing\"\n },\n \"listeners\": [\n {\n \"name\": \"my_listener\",\n \"protocol_port\": 80,\n \"allowed_cidrs\": [\n \"10.0.0.0/8\"\n ],\n \"connection_limit\": 100000,\n \"insert_x_forwarded\": false,\n \"pools\": [\n {\n \"name\": \"pool_name\",\n \"ca_secret_id\": \"<string>\",\n \"crl_secret_id\": \"<string>\",\n \"healthmonitor\": {\n \"delay\": 10,\n \"domain_name\": \"example.com\",\n \"http_method\": \"GET\",\n \"http_version\": \"1.1\",\n \"max_retries\": 3,\n \"max_retries_down\": 3,\n \"timeout\": 5,\n \"type\": \"HTTP\",\n \"url_path\": \"/\"\n },\n \"members\": [\n {\n \"address\": \"192.168.1.101\",\n \"instance_id\": \"a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9\",\n \"protocol_port\": 8000,\n \"weight\": 2\n },\n {\n \"address\": \"192.168.1.102\",\n \"instance_id\": \"169942e0-9b53-42df-95ef-1a8b6525c2bd\",\n \"protocol_port\": 8000,\n \"weight\": 4\n }\n ],\n \"secret_id\": \"<string>\",\n \"session_persistence\": {\n \"cookie_name\": \"cookie_name\",\n \"type\": \"APP_COOKIE\"\n },\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": 43200000\n }\n ],\n \"secret_id\": \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"sni_secret_id\": [\n \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"eb121225-7ded-4ff3-ae1f-599e145dd7cb\"\n ],\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": null,\n \"user_list\": [\n {\n \"encrypted_password\": \"$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5\",\n \"username\": \"admin\"\n }\n ]\n }\n ],\n \"logging\": {\n \"destination_region_id\": 1,\n \"enabled\": true,\n \"retention_policy\": {\n \"period\": 45\n },\n \"topic_name\": \"my-log-name\"\n },\n \"preferred_connectivity\": \"L2\",\n \"tags\": {},\n \"vip_network_id\": \"ac307687-31a4-4a11-a949-6bea1b2878f5\",\n \"vip_port_id\": \"ff83e13a-b256-4be2-ba5d-028d3f0ab450\",\n \"vip_subnet_id\": \"4e7802d3-5023-44b8-b298-7726558fddf4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"new_load_balancer\",\n \"flavor\": \"lb1-1-2\",\n \"floating_ip\": {\n \"source\": \"existing\"\n },\n \"listeners\": [\n {\n \"name\": \"my_listener\",\n \"protocol_port\": 80,\n \"allowed_cidrs\": [\n \"10.0.0.0/8\"\n ],\n \"connection_limit\": 100000,\n \"insert_x_forwarded\": false,\n \"pools\": [\n {\n \"name\": \"pool_name\",\n \"ca_secret_id\": \"<string>\",\n \"crl_secret_id\": \"<string>\",\n \"healthmonitor\": {\n \"delay\": 10,\n \"domain_name\": \"example.com\",\n \"http_method\": \"GET\",\n \"http_version\": \"1.1\",\n \"max_retries\": 3,\n \"max_retries_down\": 3,\n \"timeout\": 5,\n \"type\": \"HTTP\",\n \"url_path\": \"/\"\n },\n \"members\": [\n {\n \"address\": \"192.168.1.101\",\n \"instance_id\": \"a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9\",\n \"protocol_port\": 8000,\n \"weight\": 2\n },\n {\n \"address\": \"192.168.1.102\",\n \"instance_id\": \"169942e0-9b53-42df-95ef-1a8b6525c2bd\",\n \"protocol_port\": 8000,\n \"weight\": 4\n }\n ],\n \"secret_id\": \"<string>\",\n \"session_persistence\": {\n \"cookie_name\": \"cookie_name\",\n \"type\": \"APP_COOKIE\"\n },\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": 43200000\n }\n ],\n \"secret_id\": \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"sni_secret_id\": [\n \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"eb121225-7ded-4ff3-ae1f-599e145dd7cb\"\n ],\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": null,\n \"user_list\": [\n {\n \"encrypted_password\": \"$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5\",\n \"username\": \"admin\"\n }\n ]\n }\n ],\n \"logging\": {\n \"destination_region_id\": 1,\n \"enabled\": true,\n \"retention_policy\": {\n \"period\": 45\n },\n \"topic_name\": \"my-log-name\"\n },\n \"preferred_connectivity\": \"L2\",\n \"tags\": {},\n \"vip_network_id\": \"ac307687-31a4-4a11-a949-6bea1b2878f5\",\n \"vip_port_id\": \"ff83e13a-b256-4be2-ba5d-028d3f0ab450\",\n \"vip_subnet_id\": \"4e7802d3-5023-44b8-b298-7726558fddf4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"new_load_balancer\",\n \"flavor\": \"lb1-1-2\",\n \"floating_ip\": {\n \"source\": \"existing\"\n },\n \"listeners\": [\n {\n \"name\": \"my_listener\",\n \"protocol_port\": 80,\n \"allowed_cidrs\": [\n \"10.0.0.0/8\"\n ],\n \"connection_limit\": 100000,\n \"insert_x_forwarded\": false,\n \"pools\": [\n {\n \"name\": \"pool_name\",\n \"ca_secret_id\": \"<string>\",\n \"crl_secret_id\": \"<string>\",\n \"healthmonitor\": {\n \"delay\": 10,\n \"domain_name\": \"example.com\",\n \"http_method\": \"GET\",\n \"http_version\": \"1.1\",\n \"max_retries\": 3,\n \"max_retries_down\": 3,\n \"timeout\": 5,\n \"type\": \"HTTP\",\n \"url_path\": \"/\"\n },\n \"members\": [\n {\n \"address\": \"192.168.1.101\",\n \"instance_id\": \"a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9\",\n \"protocol_port\": 8000,\n \"weight\": 2\n },\n {\n \"address\": \"192.168.1.102\",\n \"instance_id\": \"169942e0-9b53-42df-95ef-1a8b6525c2bd\",\n \"protocol_port\": 8000,\n \"weight\": 4\n }\n ],\n \"secret_id\": \"<string>\",\n \"session_persistence\": {\n \"cookie_name\": \"cookie_name\",\n \"type\": \"APP_COOKIE\"\n },\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": 43200000\n }\n ],\n \"secret_id\": \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"sni_secret_id\": [\n \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"eb121225-7ded-4ff3-ae1f-599e145dd7cb\"\n ],\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": null,\n \"user_list\": [\n {\n \"encrypted_password\": \"$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5\",\n \"username\": \"admin\"\n }\n ]\n }\n ],\n \"logging\": {\n \"destination_region_id\": 1,\n \"enabled\": true,\n \"retention_policy\": {\n \"period\": 45\n },\n \"topic_name\": \"my-log-name\"\n },\n \"preferred_connectivity\": \"L2\",\n \"tags\": {},\n \"vip_network_id\": \"ac307687-31a4-4a11-a949-6bea1b2878f5\",\n \"vip_port_id\": \"ff83e13a-b256-4be2-ba5d-028d3f0ab450\",\n \"vip_subnet_id\": \"4e7802d3-5023-44b8-b298-7726558fddf4\"\n}"
response = http.request(request)
puts response.read_body{
"tasks": [
"d478ae29-dedc-4869-82f0-96104425f565"
]
}Create load balancer
curl --request POST \
--url https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "new_load_balancer",
"flavor": "lb1-1-2",
"floating_ip": {
"source": "existing"
},
"listeners": [
{
"name": "my_listener",
"protocol_port": 80,
"allowed_cidrs": [
"10.0.0.0/8"
],
"connection_limit": 100000,
"insert_x_forwarded": false,
"pools": [
{
"name": "pool_name",
"ca_secret_id": "<string>",
"crl_secret_id": "<string>",
"healthmonitor": {
"delay": 10,
"domain_name": "example.com",
"http_method": "GET",
"http_version": "1.1",
"max_retries": 3,
"max_retries_down": 3,
"timeout": 5,
"type": "HTTP",
"url_path": "/"
},
"members": [
{
"address": "192.168.1.101",
"instance_id": "a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9",
"protocol_port": 8000,
"weight": 2
},
{
"address": "192.168.1.102",
"instance_id": "169942e0-9b53-42df-95ef-1a8b6525c2bd",
"protocol_port": 8000,
"weight": 4
}
],
"secret_id": "<string>",
"session_persistence": {
"cookie_name": "cookie_name",
"type": "APP_COOKIE"
},
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": 43200000
}
],
"secret_id": "f2e734d0-fa2b-42c2-ad33-4c6db5101e00",
"sni_secret_id": [
"f2e734d0-fa2b-42c2-ad33-4c6db5101e00",
"eb121225-7ded-4ff3-ae1f-599e145dd7cb"
],
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": null,
"user_list": [
{
"encrypted_password": "$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5",
"username": "admin"
}
]
}
],
"logging": {
"destination_region_id": 1,
"enabled": true,
"retention_policy": {
"period": 45
},
"topic_name": "my-log-name"
},
"preferred_connectivity": "L2",
"tags": {},
"vip_network_id": "ac307687-31a4-4a11-a949-6bea1b2878f5",
"vip_port_id": "ff83e13a-b256-4be2-ba5d-028d3f0ab450",
"vip_subnet_id": "4e7802d3-5023-44b8-b298-7726558fddf4"
}
'import requests
url = "https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}"
payload = {
"name": "new_load_balancer",
"flavor": "lb1-1-2",
"floating_ip": { "source": "existing" },
"listeners": [
{
"name": "my_listener",
"protocol_port": 80,
"allowed_cidrs": ["10.0.0.0/8"],
"connection_limit": 100000,
"insert_x_forwarded": False,
"pools": [
{
"name": "pool_name",
"ca_secret_id": "<string>",
"crl_secret_id": "<string>",
"healthmonitor": {
"delay": 10,
"domain_name": "example.com",
"http_method": "GET",
"http_version": "1.1",
"max_retries": 3,
"max_retries_down": 3,
"timeout": 5,
"type": "HTTP",
"url_path": "/"
},
"members": [
{
"address": "192.168.1.101",
"instance_id": "a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9",
"protocol_port": 8000,
"weight": 2
},
{
"address": "192.168.1.102",
"instance_id": "169942e0-9b53-42df-95ef-1a8b6525c2bd",
"protocol_port": 8000,
"weight": 4
}
],
"secret_id": "<string>",
"session_persistence": {
"cookie_name": "cookie_name",
"type": "APP_COOKIE"
},
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": 43200000
}
],
"secret_id": "f2e734d0-fa2b-42c2-ad33-4c6db5101e00",
"sni_secret_id": ["f2e734d0-fa2b-42c2-ad33-4c6db5101e00", "eb121225-7ded-4ff3-ae1f-599e145dd7cb"],
"timeout_client_data": 50000,
"timeout_member_connect": 50000,
"timeout_member_data": None,
"user_list": [
{
"encrypted_password": "$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5",
"username": "admin"
}
]
}
],
"logging": {
"destination_region_id": 1,
"enabled": True,
"retention_policy": { "period": 45 },
"topic_name": "my-log-name"
},
"preferred_connectivity": "L2",
"tags": {},
"vip_network_id": "ac307687-31a4-4a11-a949-6bea1b2878f5",
"vip_port_id": "ff83e13a-b256-4be2-ba5d-028d3f0ab450",
"vip_subnet_id": "4e7802d3-5023-44b8-b298-7726558fddf4"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'new_load_balancer',
flavor: 'lb1-1-2',
floating_ip: {source: 'existing'},
listeners: [
{
name: 'my_listener',
protocol_port: 80,
allowed_cidrs: ['10.0.0.0/8'],
connection_limit: 100000,
insert_x_forwarded: false,
pools: [
{
name: 'pool_name',
ca_secret_id: '<string>',
crl_secret_id: '<string>',
healthmonitor: {
delay: 10,
domain_name: 'example.com',
http_method: 'GET',
http_version: '1.1',
max_retries: 3,
max_retries_down: 3,
timeout: 5,
type: 'HTTP',
url_path: '/'
},
members: [
{
address: '192.168.1.101',
instance_id: 'a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9',
protocol_port: 8000,
weight: 2
},
{
address: '192.168.1.102',
instance_id: '169942e0-9b53-42df-95ef-1a8b6525c2bd',
protocol_port: 8000,
weight: 4
}
],
secret_id: '<string>',
session_persistence: {cookie_name: 'cookie_name', type: 'APP_COOKIE'},
timeout_client_data: 50000,
timeout_member_connect: 50000,
timeout_member_data: 43200000
}
],
secret_id: 'f2e734d0-fa2b-42c2-ad33-4c6db5101e00',
sni_secret_id: ['f2e734d0-fa2b-42c2-ad33-4c6db5101e00', 'eb121225-7ded-4ff3-ae1f-599e145dd7cb'],
timeout_client_data: 50000,
timeout_member_connect: 50000,
timeout_member_data: null,
user_list: [
{
encrypted_password: '$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5',
username: 'admin'
}
]
}
],
logging: {
destination_region_id: 1,
enabled: true,
retention_policy: {period: 45},
topic_name: 'my-log-name'
},
preferred_connectivity: 'L2',
tags: {},
vip_network_id: 'ac307687-31a4-4a11-a949-6bea1b2878f5',
vip_port_id: 'ff83e13a-b256-4be2-ba5d-028d3f0ab450',
vip_subnet_id: '4e7802d3-5023-44b8-b298-7726558fddf4'
})
};
fetch('https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'new_load_balancer',
'flavor' => 'lb1-1-2',
'floating_ip' => [
'source' => 'existing'
],
'listeners' => [
[
'name' => 'my_listener',
'protocol_port' => 80,
'allowed_cidrs' => [
'10.0.0.0/8'
],
'connection_limit' => 100000,
'insert_x_forwarded' => false,
'pools' => [
[
'name' => 'pool_name',
'ca_secret_id' => '<string>',
'crl_secret_id' => '<string>',
'healthmonitor' => [
'delay' => 10,
'domain_name' => 'example.com',
'http_method' => 'GET',
'http_version' => '1.1',
'max_retries' => 3,
'max_retries_down' => 3,
'timeout' => 5,
'type' => 'HTTP',
'url_path' => '/'
],
'members' => [
[
'address' => '192.168.1.101',
'instance_id' => 'a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9',
'protocol_port' => 8000,
'weight' => 2
],
[
'address' => '192.168.1.102',
'instance_id' => '169942e0-9b53-42df-95ef-1a8b6525c2bd',
'protocol_port' => 8000,
'weight' => 4
]
],
'secret_id' => '<string>',
'session_persistence' => [
'cookie_name' => 'cookie_name',
'type' => 'APP_COOKIE'
],
'timeout_client_data' => 50000,
'timeout_member_connect' => 50000,
'timeout_member_data' => 43200000
]
],
'secret_id' => 'f2e734d0-fa2b-42c2-ad33-4c6db5101e00',
'sni_secret_id' => [
'f2e734d0-fa2b-42c2-ad33-4c6db5101e00',
'eb121225-7ded-4ff3-ae1f-599e145dd7cb'
],
'timeout_client_data' => 50000,
'timeout_member_connect' => 50000,
'timeout_member_data' => null,
'user_list' => [
[
'encrypted_password' => '$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5',
'username' => 'admin'
]
]
]
],
'logging' => [
'destination_region_id' => 1,
'enabled' => true,
'retention_policy' => [
'period' => 45
],
'topic_name' => 'my-log-name'
],
'preferred_connectivity' => 'L2',
'tags' => [
],
'vip_network_id' => 'ac307687-31a4-4a11-a949-6bea1b2878f5',
'vip_port_id' => 'ff83e13a-b256-4be2-ba5d-028d3f0ab450',
'vip_subnet_id' => '4e7802d3-5023-44b8-b298-7726558fddf4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}"
payload := strings.NewReader("{\n \"name\": \"new_load_balancer\",\n \"flavor\": \"lb1-1-2\",\n \"floating_ip\": {\n \"source\": \"existing\"\n },\n \"listeners\": [\n {\n \"name\": \"my_listener\",\n \"protocol_port\": 80,\n \"allowed_cidrs\": [\n \"10.0.0.0/8\"\n ],\n \"connection_limit\": 100000,\n \"insert_x_forwarded\": false,\n \"pools\": [\n {\n \"name\": \"pool_name\",\n \"ca_secret_id\": \"<string>\",\n \"crl_secret_id\": \"<string>\",\n \"healthmonitor\": {\n \"delay\": 10,\n \"domain_name\": \"example.com\",\n \"http_method\": \"GET\",\n \"http_version\": \"1.1\",\n \"max_retries\": 3,\n \"max_retries_down\": 3,\n \"timeout\": 5,\n \"type\": \"HTTP\",\n \"url_path\": \"/\"\n },\n \"members\": [\n {\n \"address\": \"192.168.1.101\",\n \"instance_id\": \"a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9\",\n \"protocol_port\": 8000,\n \"weight\": 2\n },\n {\n \"address\": \"192.168.1.102\",\n \"instance_id\": \"169942e0-9b53-42df-95ef-1a8b6525c2bd\",\n \"protocol_port\": 8000,\n \"weight\": 4\n }\n ],\n \"secret_id\": \"<string>\",\n \"session_persistence\": {\n \"cookie_name\": \"cookie_name\",\n \"type\": \"APP_COOKIE\"\n },\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": 43200000\n }\n ],\n \"secret_id\": \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"sni_secret_id\": [\n \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"eb121225-7ded-4ff3-ae1f-599e145dd7cb\"\n ],\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": null,\n \"user_list\": [\n {\n \"encrypted_password\": \"$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5\",\n \"username\": \"admin\"\n }\n ]\n }\n ],\n \"logging\": {\n \"destination_region_id\": 1,\n \"enabled\": true,\n \"retention_policy\": {\n \"period\": 45\n },\n \"topic_name\": \"my-log-name\"\n },\n \"preferred_connectivity\": \"L2\",\n \"tags\": {},\n \"vip_network_id\": \"ac307687-31a4-4a11-a949-6bea1b2878f5\",\n \"vip_port_id\": \"ff83e13a-b256-4be2-ba5d-028d3f0ab450\",\n \"vip_subnet_id\": \"4e7802d3-5023-44b8-b298-7726558fddf4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"new_load_balancer\",\n \"flavor\": \"lb1-1-2\",\n \"floating_ip\": {\n \"source\": \"existing\"\n },\n \"listeners\": [\n {\n \"name\": \"my_listener\",\n \"protocol_port\": 80,\n \"allowed_cidrs\": [\n \"10.0.0.0/8\"\n ],\n \"connection_limit\": 100000,\n \"insert_x_forwarded\": false,\n \"pools\": [\n {\n \"name\": \"pool_name\",\n \"ca_secret_id\": \"<string>\",\n \"crl_secret_id\": \"<string>\",\n \"healthmonitor\": {\n \"delay\": 10,\n \"domain_name\": \"example.com\",\n \"http_method\": \"GET\",\n \"http_version\": \"1.1\",\n \"max_retries\": 3,\n \"max_retries_down\": 3,\n \"timeout\": 5,\n \"type\": \"HTTP\",\n \"url_path\": \"/\"\n },\n \"members\": [\n {\n \"address\": \"192.168.1.101\",\n \"instance_id\": \"a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9\",\n \"protocol_port\": 8000,\n \"weight\": 2\n },\n {\n \"address\": \"192.168.1.102\",\n \"instance_id\": \"169942e0-9b53-42df-95ef-1a8b6525c2bd\",\n \"protocol_port\": 8000,\n \"weight\": 4\n }\n ],\n \"secret_id\": \"<string>\",\n \"session_persistence\": {\n \"cookie_name\": \"cookie_name\",\n \"type\": \"APP_COOKIE\"\n },\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": 43200000\n }\n ],\n \"secret_id\": \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"sni_secret_id\": [\n \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"eb121225-7ded-4ff3-ae1f-599e145dd7cb\"\n ],\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": null,\n \"user_list\": [\n {\n \"encrypted_password\": \"$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5\",\n \"username\": \"admin\"\n }\n ]\n }\n ],\n \"logging\": {\n \"destination_region_id\": 1,\n \"enabled\": true,\n \"retention_policy\": {\n \"period\": 45\n },\n \"topic_name\": \"my-log-name\"\n },\n \"preferred_connectivity\": \"L2\",\n \"tags\": {},\n \"vip_network_id\": \"ac307687-31a4-4a11-a949-6bea1b2878f5\",\n \"vip_port_id\": \"ff83e13a-b256-4be2-ba5d-028d3f0ab450\",\n \"vip_subnet_id\": \"4e7802d3-5023-44b8-b298-7726558fddf4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/loadbalancers/{project_id}/{region_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"new_load_balancer\",\n \"flavor\": \"lb1-1-2\",\n \"floating_ip\": {\n \"source\": \"existing\"\n },\n \"listeners\": [\n {\n \"name\": \"my_listener\",\n \"protocol_port\": 80,\n \"allowed_cidrs\": [\n \"10.0.0.0/8\"\n ],\n \"connection_limit\": 100000,\n \"insert_x_forwarded\": false,\n \"pools\": [\n {\n \"name\": \"pool_name\",\n \"ca_secret_id\": \"<string>\",\n \"crl_secret_id\": \"<string>\",\n \"healthmonitor\": {\n \"delay\": 10,\n \"domain_name\": \"example.com\",\n \"http_method\": \"GET\",\n \"http_version\": \"1.1\",\n \"max_retries\": 3,\n \"max_retries_down\": 3,\n \"timeout\": 5,\n \"type\": \"HTTP\",\n \"url_path\": \"/\"\n },\n \"members\": [\n {\n \"address\": \"192.168.1.101\",\n \"instance_id\": \"a7e7e8d6-0bf7-4ac9-8170-831b47ee2ba9\",\n \"protocol_port\": 8000,\n \"weight\": 2\n },\n {\n \"address\": \"192.168.1.102\",\n \"instance_id\": \"169942e0-9b53-42df-95ef-1a8b6525c2bd\",\n \"protocol_port\": 8000,\n \"weight\": 4\n }\n ],\n \"secret_id\": \"<string>\",\n \"session_persistence\": {\n \"cookie_name\": \"cookie_name\",\n \"type\": \"APP_COOKIE\"\n },\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": 43200000\n }\n ],\n \"secret_id\": \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"sni_secret_id\": [\n \"f2e734d0-fa2b-42c2-ad33-4c6db5101e00\",\n \"eb121225-7ded-4ff3-ae1f-599e145dd7cb\"\n ],\n \"timeout_client_data\": 50000,\n \"timeout_member_connect\": 50000,\n \"timeout_member_data\": null,\n \"user_list\": [\n {\n \"encrypted_password\": \"$5$isRr.HJ1IrQP38.m$oViu3DJOpUG2ZsjCBtbITV3mqpxxbZfyWJojLPNSPO5\",\n \"username\": \"admin\"\n }\n ]\n }\n ],\n \"logging\": {\n \"destination_region_id\": 1,\n \"enabled\": true,\n \"retention_policy\": {\n \"period\": 45\n },\n \"topic_name\": \"my-log-name\"\n },\n \"preferred_connectivity\": \"L2\",\n \"tags\": {},\n \"vip_network_id\": \"ac307687-31a4-4a11-a949-6bea1b2878f5\",\n \"vip_port_id\": \"ff83e13a-b256-4be2-ba5d-028d3f0ab450\",\n \"vip_subnet_id\": \"4e7802d3-5023-44b8-b298-7726558fddf4\"\n}"
response = http.request(request)
puts response.read_body{
"tasks": [
"d478ae29-dedc-4869-82f0-96104425f565"
]
}Authorizations
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234$abcdef
Path Parameters
Project ID
1
Region ID
7
Body
Load balancer name.
^[a-zA-Z0-9][a-zA-Z 0-9._\-]{1,61}[a-zA-Z0-9._]$"new_load_balancer"
Load balancer flavor name
"lb1-1-2"
"lb2-2-2"
Floating IP configuration for assignment
- New floating IP
- Existing floating IP
Show child attributes
Show child attributes
{ "source": "existing" }
Load balancer listeners. Maximum 50 per LB (excluding Prometheus endpoint listener).
51Show child attributes
Show child attributes
Logging configuration
Show child attributes
Show child attributes
Preferred option to establish connectivity between load balancer and its pools members. L2 provides best performance, L3 provides less IPs usage. It is taking effect only if instance_id + ip_address is provided, not subnet_id + ip_address, because we're considering this as intentional subnet_id specification.
L2, L3 "L2"
"L3"
Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling efficient filtering and grouping for better organization and management. Both tag keys and values have a maximum length of 255 characters. Some tags are read-only and cannot be modified by the user. Tags are also integrated with cost reports, allowing cost data to be filtered based on tag keys or values.
Show child attributes
Show child attributes
{ "my-tag": "my-tag-value" }
IP family for load balancer subnet auto-selection if vip_network_id is specified
dual, ipv4, ipv6 "ipv4"
Network ID for load balancer. If not specified, default external network will be used. Mutually exclusive with vip_port_id
"ac307687-31a4-4a11-a949-6bea1b2878f5"
Existing Reserved Fixed IP port ID for load balancer. Mutually exclusive with vip_network_id
"ff83e13a-b256-4be2-ba5d-028d3f0ab450"
Subnet ID for load balancer. If not specified, any subnet from vip_network_id will be selected. Ignored when vip_network_id is not specified.
"4e7802d3-5023-44b8-b298-7726558fddf4"
Response
OK
List of task IDs representing asynchronous operations. Use these IDs to monitor operation progress:
GET /v1/tasks/{task_id}- Check individual task status and details Poll task status until completion (FINISHED/ERROR) before proceeding with dependent operations.
["d478ae29-dedc-4869-82f0-96104425f565"]
Was this page helpful?