wave
rectangle square backgroundrectangle square backgroundrectangle square backgroundrectangle square backgroundrectangle square backgroundrectangle square backgroundProduct 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 = DropletKit::LoadBalancer.new( name: ‘example-lb-001’, algorithm: ‘round_robin’, tag: ‘web:prod’, redirect_http_to_https: true, region: ‘nyc3’, forwarding_rules: [ DropletKit::ForwardingRule.new( entry_protocol: ‘http’, entry_port: 80, target_protocol: ‘http’, target_port: 80, certificate_id: ‘’, tls_passthrough: false ) ], sticky_sessions: DropletKit::StickySession.new( type: ‘none’, cookie_name: ‘’, cookie_ttl_seconds: nil ), health_check: DropletKit::HealthCheck.new( 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

Share

TwitterFacebookLinkedInHackerNews
You've got unique business needs. We've got powerful solutions to meet them. Chat with us to get started.Contact sales

Related Articles

Backup Management for Docker-based Applications
product-updates

Backup Management for Docker-based Applications

May 2, 20233 min read

SnapShooter introduces new features to back up the modern cloud
product-updates

SnapShooter introduces new features to back up the modern cloud

May 2, 20233 min read

How to choose a data center location for your business
product-updates

How to choose a data center location for your business

April 21, 20233 min read

  • Twitchtv
  • Twitter
  • Facebook
  • Instagram
  • YouTube
  • LinkedIn
  • Dev.to
  • GlassDoor
  • BuiltInNYC
Sea floor left
Sea floor middle
Sea floor right