Cobra Forum

Plesk Panel => Web Application => Topic started by: Suhitha on Sep 05, 2025, 06:52 AM

Title: How to Attach an Instance to a Vultr Load Balancer
Post by: Suhitha on Sep 05, 2025, 06:52 AM
Question: How to Attach an Instance to a Vultr Load Balancer

A Load Balancer distributes incoming traffic across multiple instances to improve performance, increase availability, and provide failover support. To function correctly, instances within the same geographic region must be attached to the Vultr Load Balancer.

Follow this guide to attach an instance to a Vultr Load Balancer on your Vultr account using the Vultr Customer Portal, API, CLI, or Terraform.


Vultr Customer Portal

1.Navigate to Products and click Load Balancers.

2.Click your target Load Balancer to open its management page.

3.In Resources, expand the location where you want to link instances.

4.In Instances, go to the desired region, and click Add Instances.

5.Select one or more instances from the same region, then click Save Changes.


Vultr API

1.Send a GET request to the List Load Balancers endpoint and note the target Load Balancer's ID.

[color=blue]console[/color]


$ curl "https://api.vultr.com/v2/load-balancers" \
    -X GET \
    -H "Authorization: Bearer ${VULTR_API_KEY}"
2.Send a GET request to the List Instances endpoint and note your target instance's ID, ensuring it is in the same geographic region as the Load Balancer.

[color=blue]console[/color]


$ curl "https://api.vultr.com/v2/instances" \
    -X GET \
    -H "Authorization: Bearer ${VULTR_API_KEY}"
3.Send a PATCH request to the Update Load Balancer endpoint to attach instances to the target Load Balancer.

[color=blue]console[/color]


$ curl "https://api.vultr.com/v2/load-balancers/{load-balancer-id}" \
    -X PATCH \
    -H "Authorization: Bearer ${VULTR_API_KEY}" \
    -H "Content-Type: application/json" \
    --data '{
        "instances": [
            "<instance_1_id>",
            "<instance_2_id>"
        ]
    }'

4.Send a GET request to the Get Load Balancer endpoint to fetch the details of the target Load Balancer.
[color=blue]console[/color]


$ curl "https://api.vultr.com/v2/load-balancers/{load-balancer-id}" \
    -X GET \
    -H "Authorization: Bearer ${VULTR_API_KEY}"


Vultr CLI

1.List all available instances and note the target Load Balancer's ID.

[color=blue]console[/color]


$ vultr-cli load-balancer list

2.List all available instances and note your target instance's ID, ensuring it is in the same geographic region as the Load Balancer.

[color=blue]console[/color]


$ vultr-cli instance list

3.Update the target Load Balancer by attaching the new instances.

[color=blue]console[/color]


$ vultr-cli load-balancer update <load-balancer-id> --instances "<instance_1_id>" "<instance_2_id>" "<instance_3_id>"

4.Get the details of the target Load Balancer.
[color=blue]console
[/color]

$ vultr-cli load-balancer get <load-balancer-id>


Terraform

1.List all available instances and note the target Load Balancer's ID.

[color=blue]console[/color]


$ vultr-cli load-balancer list

2.List all available instances and note your target instance's ID, ensuring it is in the same geographic region as the Load Balancer.

[color=blue]console[/color]


$ vultr-cli instance list

3.Update the target Load Balancer by attaching the new instances.

[color=blue]console[/color]


$ vultr-cli load-balancer update <load-balancer-id> --instances "<instance_1_id>" "<instance_2_id>" "<instance_3_id>"
4.Get the details of the target Load Balancer.

[color=blue]console[/color]


$ vultr-cli load-balancer get <load-balancer-id>