Skip to navigation

A target is a VM and a port that a load balancer sends traffic to. Attaching a VM means adding it as a target; there is no separate “attach” button. You pick VMs when you create the load balancer, and you can add or remove them later. The load balancer health-checks each target and sends traffic only to the healthy ones.

When to use each kind of target

KindIn the APIUse it forIn the portal
VM (recommended){"kind": "vm", "resource_id": "vm-7f3c2d1e", "port": 8080}A VM in the same location as the load balancer. Where the location’s private_targets is false, the VM needs its own public IP address.Add VMs
Private IP{"kind": "ip", "address": "10.0.0.10", "port": 8080}A private address in a VPC (10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16). Works only in a location whose capabilities.private_targets is true.Not offered

resource_id is the VM’s ID: the id that GET /compute/cloud-vms returns for the VM. Check a location’s capabilities with GET /networking/load-balancers/regions.

How it works

  1. You choose the targets and the backend port. In the portal, every forwarding rule sends traffic to all the VMs you pick, on the rule’s backend port. In the API, each target has its own port.
  2. Before anything is reserved, IBEE checks that the location can reach every target. If it can’t reach one, the request is refused with 422 target_not_usable, and nothing is reserved.
  3. The load balancer attaches the targets. In the API, conditions.backend_ready becomes true; in the portal, the status leaves “Connecting to your targets”.
  4. The load balancer health-checks each target on its backend port. Targets that pass get traffic, chosen by the algorithm.

Before you begin

  • Running VMs in the same location as the load balancer, with the same app listening on the same port on every VM. See Create a VM.
  • A public IP address on each VM, unless the location supports private targets. The public_ip field of GET /compute/cloud-vms, and the VM’s page in the portal, show it.
  • The app port open in each VM’s firewall group. The load balancer connects to that port for traffic and for health checks, so a rule that allows only your own IP address isn’t enough. See Create firewall rules. Also check the firewall inside the VM (ufw, firewalld or Windows Firewall).
  • A little patience with new VMs. A new VM reports running about 20 seconds before its SSH or web server answers. Wait before you test traffic through the load balancer.

Add VMs when you create the load balancer

1

Check each VM answers

From your computer, connect to the app port on each VM’s public address:

curl -i http://203.0.113.10:8080/
curl -i http://203.0.113.11:8080/

Each should answer. If a request times out, open the port in the VM’s firewall group first.

2

Open the create form

Under Network & Security, click Load Balancer, then Create Load Balancer. Choose the Location where your VMs run.

3

Set the backend port

Under Forwarding rules, set the Backend protocol and Port to the port your app listens on, for example HTTP 8080.

4

Add the VMs

Under Targets, click Add VMs. The list shows the workspace’s VMs in the chosen location; type in Search VMs to filter it. Click each VM to select it. The selected VMs appear above the button. To remove one, click the × next to it.

5

Create

Finish the rest of the form and click Create Load Balancer.

Add or remove VMs later

In the portal: open the load balancer, click Settings, then Edit next to Targets. Add or remove VMs and click Save. The Overview tab shows the number of targets.

With the API: read the load balancer, change the targets list in its specification, and send the whole specification back with PUT and the version you read. The list you send replaces the current one, so include every VM you want to keep.

curl -X PUT "https://api.ibee.ai/v1/networking/load-balancers/01a20a76-3031-7a94-aa8d-c8ed59184c0f?workspace_id=710995" \
-H "Authorization: Bearer $IBEE_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: orders-web-add-vm-3" \
-d '{
"version": 2,
"specification": {
"name": "orders-web",
"region_id": "01a1e3fe-3104-7563-ad37-95f90ab93ef3",
"traffic_type": "http",
"node_count": 1,
"listeners": [
{"name": "http-80", "protocol": "HTTP", "port": 80, "target_group": "web"}
],
"target_groups": [
{
"name": "web",
"protocol": "HTTP",
"targets": [
{"kind": "vm", "resource_id": "vm-7f3c2d1e", "port": 8080},
{"kind": "vm", "resource_id": "vm-8a4d3e2f", "port": 8080},
{"kind": "vm", "resource_id": "vm-9b5e4f3a", "port": 8080}
],
"health_check": {"protocol": "TCP"}
}
]
}
}'

The call answers 202 with an update operation. A stale version answers 409 version_conflict. The token needs load-balancer.write. See Change a load balancer.

Targets of a load balancer made by a Kubernetes cluster (managed_by ccm) can’t be changed here. Change the Service in your cluster instead.

Before you delete a VM that is a target, remove it from the load balancer first, in the portal or with a PUT.

Verify

  1. Open the load balancer. The Overview tab shows Targets with the number of VMs and their names.

  2. Make each VM identify itself, for example with a /whoami page that returns the VM’s hostname.

  3. Send several requests to the load balancer’s address and count the answers:

    for i in $(seq 1 20); do curl -s http://103.149.10.86/whoami; echo; done | sort | uniq -c

    Every healthy VM should appear. See Algorithms for how the requests are spread.

Limits

ItemValue
TargetsUp to 100 per target group. The portal applies one list to every forwarding rule.
Target port1–65535
Same target twiceNot allowed: “The same target is listed twice”
LocationTargets must be in the load balancer’s location
Private addressesOnly where capabilities.private_targets is true
WeightsNone. Every healthy target is treated the same.

Troubleshooting

You seeWhat it meansWhat to do
422 target_not_usable, for example “A backend VM is not available to this tenant”The location can’t reach a target: for example a VM without its own public IP, or a private address where private_targets is false. Nothing was reserved.Use VMs with their own public IP in the same location, as kind vm with their resource_id.
”No VMs in this location” under Add VMsThe workspace has no VM in the chosen locationCreate a VM there, or choose the location where your VMs run.
”Add at least one target”No VM is selectedClick Add VMs and select at least one.
”isn’t a private IP address” (portal)An IP target uses an address outside the private rangesUse the VM as a vm target instead.
The status shows “Connecting to your targets” for a long timeThe load balancer can’t attach a target yetCheck that each VM is running and has its own public IP.
”One or more targets couldn’t be reached”The load balancer couldn’t resolve a targetCheck that every target VM still exists and is running. Remove or replace any that isn’t.
A VM never gets trafficIts health check failsRun curl -i http://VM-IP:PORT/ from outside. Fix the firewall rule or the app. See Health checks.
Traffic fails right after you created the VMsThe VMs report running before their services answerWait about 20 seconds and try again.
After a PUT, some VMs are goneThe targets list replaces the old oneSend every VM you want to keep.