Question

Load Balancer: Get number of healthy nodes through API

Posted July 30, 2021 131 views
DigitalOcean Managed Load BalancersDigitalOcean API and CLI (doctl)

For my deployment, I want to check the health state of the Load Balancer first, then remove all “green” nodes, deploy to those, then add them to the LB again, then wait for 100% health before proceeding to deploy to “blue” nodes.

However, I can’t find the option to check the health status of the load balancer (i.e. the “2/2 Healthy Droplets” that is visible in the dashboard and even in the project overview).

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hey @MineralWorm,

As far as I can see this is not yet available out of the box according to the API documentation here:

https://docs.digitalocean.com/reference/api/api-reference/#operation/get_load_balancer

But this sounds like a great idea, sounds like it’d be super useful!

The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.

https://ideas.digitalocean.com/

In the meantime, as a lengthy workaround, what you could do is do a ‘manual’ health check for each of the Droplets in question. With a GET request to https://api.digitalocean.com/v2/load_balancers/LB_ID, you would get back a list of the Droplet IDs that are part of the load balancer, and you could loop through that list and do a curl to your health check endpoint.

Hope that helps!
- Bobby.

  • Hi Bobby, cheers for your reply.

    In the meantime, as a lengthy workaround, what you could do is do a ‘manual’ health check for each of the Droplets in question.

    This is actually what I’m doing now, but it’s not a great indicator, as the node seems healthy, but the LB still needs a few checks to finally accept the node as healthy. If I’m already starting the deployment during this phase with removing the blue nodes, the LB has no healthy nodes left.

    • Hello,

      What I could suggest is adding a slight delay of a few seconds into your health check logic before proceeding with the other nodes.

      If you’ve posted an idea on the idea board, feel free to share it here and I will make sure to upvote it as well.

      Regards,
      Bobby