Product updates

More Ways to Work with Load Balancers

Posted: March 15, 20175 min read

When building new products at DigitalOcean, one of our goals is to ensure that they’re simple to use and developer friendly. And that goes beyond the control panel; we aim to provide intuitive APIs and tools for each of our products. Since the release of Load Balancers last month, we’ve worked to incorporate them into our API client libraries and command line client. We’ve also seen community-supported open source projects extended to support Load Balancers.

Today, we want to share several new ways you can interact with Load Balancers.

Command Line: doctl

doctl is our easy-to-use, official command line client. Load Balancer support landed in version v1.6.0. You can download the release from GitHub or install it using Homebrew on Mac:

brew install doctl

You can use doctl for anything you can do in our control panel. For example, here’s how you would create a Load Balancer:

doctl compute load-balancer create --name “example-01” \ --region “nyc3” --tag-name “web:prod” \ --algorithm “round_robin” \ --forwarding-rules \ “entry_protocol:http,entry_port:80,target_protocol:http,target_port:80”

Find doctl’s full documentation in this DigitalOcean tutorial.

Go: godo

We’re big fans of Go, and godo is the way to interact with DigitalOcean using Go. Load Balancer support is included in the recently tagged v1.0.0 release. Here’s an example:

createRequest := &godo.LoadBalancerRequest{ Name: “example-01”, Algorithm: “round_robin”, Region: “nyc3”, ForwardingRules: []godo.ForwardingRule{ { EntryProtocol: “http”, EntryPort: 80, TargetProtocol: “http”, TargetPort: 80, }, }, HealthCheck: &godo.HealthCheck{ Protocol: “http”, Port: 80, Path: “/”, CheckIntervalSeconds: 10, ResponseTimeoutSeconds: 5, HealthyThreshold: 5, UnhealthyThreshold: 3, }, StickySessions: &godo.StickySessions{ Type: “none”, }, Tag: “web:prod”, RedirectHttpToHttps: false, } lb, _, err := client.LoadBalancers.Create(ctx, createRequest)

The library’s full documentation is available on GoDoc.

Ruby: droplet_kit

droplet_kit is our Ruby API client library. Version 2.1.0 has Load Balancer support and is now available on Rubygems. You can install it with this command:

gem install droplet_kit

And you can create a new Load Balancer like so:

load_balancer = name: ‘example-lb-001’, algorithm: ‘round_robin’, tag: ‘web:prod’, redirect_http_to_https: true, region: ‘nyc3’, forwarding_rules: [ entry_protocol: ‘http’, entry_port: 80, target_protocol: ‘http’, target_port: 80, certificate_id: ‘’, tls_passthrough: false ) ], sticky_sessions: type: ‘none’, cookie_name: ‘’, cookie_ttl_seconds: nil ), health_check: protocol: ‘http’, port: 80, path: ‘/’, check_interval_seconds: 10, response_timeout_seconds: 5, healthy_threshold: 5, unhealthy_threshold: 3 ) ) client.load_balancers.create(load_balancer)

Community Supported

Besides our official open source projects, there are two community contributions we’d like to highlight:


HashiCorp’s declarative infrastructure tool, Terraform, added the digitalocean_loadbalancer resource shortly after the launch of Load Balancers. It’s now available in their v0.8.8 release.


Lorenzo Setale’s Python API client library, python-digitalocean, shipped Load Balancer support in yesterday’s v1.11 release. It can be installed using PIP: `pip install -U python-digitalocean`

Thanks to our colleagues Viola and Andrew for working on these features, and the open source community for including Load Balancer support in their projects. In particular, we want to give a special shout out to Paul Stack and the rest of our friends at HashiCorp who added support to Terraform so quickly. You rock!

We’re excited to see more tools add Load Balancer support. If you’re the maintainer of a project that has added support, Tweet us @digitalocean. We can help spread the word!

Rafael Rosa

Product Manager, High Availability


Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!Sign up

Related Articles

Introducing the next evolution of DigitalOcean Backups

Introducing the next evolution of DigitalOcean Backups

February 8, 20243 min read

Cilium Hubble now included with DigitalOcean Kubernetes at no cost

Cilium Hubble now included with DigitalOcean Kubernetes at no cost

February 1, 20243 min read

Paperspace by DigitalOcean now offering NVIDIA H100 GPUs

Paperspace by DigitalOcean now offering NVIDIA H100 GPUs

January 18, 20243 min read