Skip to content

Load Balancers

Create a New Load Balancer
client.GPUDroplets.LoadBalancers.New(ctx, body) (*GPUDropletLoadBalancerNewResponse, error)
post/v2/load_balancers
List All Load Balancers
client.GPUDroplets.LoadBalancers.List(ctx, query) (*GPUDropletLoadBalancerListResponse, error)
get/v2/load_balancers
Retrieve an Existing Load Balancer
client.GPUDroplets.LoadBalancers.Get(ctx, lbID) (*GPUDropletLoadBalancerGetResponse, error)
get/v2/load_balancers/{lb_id}
Update a Load Balancer
client.GPUDroplets.LoadBalancers.Update(ctx, lbID, body) (*GPUDropletLoadBalancerUpdateResponse, error)
put/v2/load_balancers/{lb_id}
Delete a Load Balancer
client.GPUDroplets.LoadBalancers.Delete(ctx, lbID) error
delete/v2/load_balancers/{lb_id}
Delete a Global Load Balancer CDN Cache
client.GPUDroplets.LoadBalancers.DeleteCache(ctx, lbID) error
delete/v2/load_balancers/{lb_id}/cache
ModelsExpand Collapse
type Domains struct{…}

An object specifying domain configurations for a Global load balancer.

CertificateID stringoptional

The ID of the TLS certificate used for SSL termination.

IsManaged booloptional

A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added.

Name stringoptional

FQDN to associate with a Global load balancer.

type ForwardingRule struct{…}

An object specifying a forwarding rule for a load balancer.

EntryPort int64

An integer representing the port on which the load balancer instance will listen.

EntryProtocol ForwardingRuleEntryProtocol

The protocol used for traffic to the load balancer. The possible values are: http, https, http2, http3, tcp, or udp. If you set the entry_protocol to udp, the target_protocol must be set to udp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.

Accepts one of the following:
const ForwardingRuleEntryProtocolHTTP ForwardingRuleEntryProtocol = "http"
const ForwardingRuleEntryProtocolHTTPS ForwardingRuleEntryProtocol = "https"
const ForwardingRuleEntryProtocolHttp2 ForwardingRuleEntryProtocol = "http2"
const ForwardingRuleEntryProtocolHttp3 ForwardingRuleEntryProtocol = "http3"
const ForwardingRuleEntryProtocolTcp ForwardingRuleEntryProtocol = "tcp"
const ForwardingRuleEntryProtocolUdp ForwardingRuleEntryProtocol = "udp"
TargetPort int64

An integer representing the port on the backend Droplets to which the load balancer will send traffic.

TargetProtocol ForwardingRuleTargetProtocol

The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: http, https, http2, tcp, or udp. If you set the target_protocol to udp, the entry_protocol must be set to udp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.

Accepts one of the following:
const ForwardingRuleTargetProtocolHTTP ForwardingRuleTargetProtocol = "http"
const ForwardingRuleTargetProtocolHTTPS ForwardingRuleTargetProtocol = "https"
const ForwardingRuleTargetProtocolHttp2 ForwardingRuleTargetProtocol = "http2"
const ForwardingRuleTargetProtocolTcp ForwardingRuleTargetProtocol = "tcp"
const ForwardingRuleTargetProtocolUdp ForwardingRuleTargetProtocol = "udp"
CertificateID stringoptional

The ID of the TLS certificate used for SSL termination if enabled.

TlsPassthrough booloptional

A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets.

type GlbSettings struct{…}

An object specifying forwarding configurations for a Global load balancer.

Cdn GlbSettingsCdnoptional

An object specifying CDN configurations for a Global load balancer.

IsEnabled booloptional

A boolean flag to enable CDN caching.

FailoverThreshold int64optional

An integer value as a percentage to indicate failure threshold to decide how the regional priorities will take effect. A value of 50 would indicate that the Global load balancer will choose a lower priority region to forward traffic to once this failure threshold has been reached for the higher priority region.

RegionPriorities map[string, int64]optional

A map of region string to an integer priority value indicating preference for which regional target a Global load balancer will forward traffic to. A lower value indicates a higher priority.

TargetPort int64optional

An integer representing the port on the target backends which the load balancer will forward traffic to.

TargetProtocol GlbSettingsTargetProtocoloptional

The protocol used for forwarding traffic from the load balancer to the target backends. The possible values are http, https and http2.

Accepts one of the following:
const GlbSettingsTargetProtocolHTTP GlbSettingsTargetProtocol = "http"
const GlbSettingsTargetProtocolHTTPS GlbSettingsTargetProtocol = "https"
const GlbSettingsTargetProtocolHttp2 GlbSettingsTargetProtocol = "http2"
type HealthCheck struct{…}

An object specifying health check settings for the load balancer.

CheckIntervalSeconds int64optional

The number of seconds between between two consecutive health checks.

HealthyThreshold int64optional

The number of times a health check must pass for a backend Droplet to be marked "healthy" and be re-added to the pool.

Path stringoptional

The path on the backend Droplets to which the load balancer instance will send a request.

Port int64optional

An integer representing the port on the backend Droplets on which the health check will attempt a connection.

Protocol HealthCheckProtocoloptional

The protocol used for health checks sent to the backend Droplets. The possible values are http, https, or tcp.

Accepts one of the following:
const HealthCheckProtocolHTTP HealthCheckProtocol = "http"
const HealthCheckProtocolHTTPS HealthCheckProtocol = "https"
const HealthCheckProtocolTcp HealthCheckProtocol = "tcp"
ResponseTimeoutSeconds int64optional

The number of seconds the load balancer instance will wait for a response until marking a health check as failed.

UnhealthyThreshold int64optional

The number of times a health check must fail for a backend Droplet to be marked "unhealthy" and be removed from the pool.

type LbFirewall struct{…}

An object specifying allow and deny rules to control traffic to the load balancer.

Allow []stringoptional

the rules for allowing traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16')

Deny []stringoptional

the rules for denying traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16')

type LoadBalancer struct{…}
ForwardingRules []ForwardingRule

An array of objects specifying the forwarding rules for a load balancer.

EntryPort int64

An integer representing the port on which the load balancer instance will listen.

EntryProtocol ForwardingRuleEntryProtocol

The protocol used for traffic to the load balancer. The possible values are: http, https, http2, http3, tcp, or udp. If you set the entry_protocol to udp, the target_protocol must be set to udp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.

Accepts one of the following:
const ForwardingRuleEntryProtocolHTTP ForwardingRuleEntryProtocol = "http"
const ForwardingRuleEntryProtocolHTTPS ForwardingRuleEntryProtocol = "https"
const ForwardingRuleEntryProtocolHttp2 ForwardingRuleEntryProtocol = "http2"
const ForwardingRuleEntryProtocolHttp3 ForwardingRuleEntryProtocol = "http3"
const ForwardingRuleEntryProtocolTcp ForwardingRuleEntryProtocol = "tcp"
const ForwardingRuleEntryProtocolUdp ForwardingRuleEntryProtocol = "udp"
TargetPort int64

An integer representing the port on the backend Droplets to which the load balancer will send traffic.

TargetProtocol ForwardingRuleTargetProtocol

The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: http, https, http2, tcp, or udp. If you set the target_protocol to udp, the entry_protocol must be set to udp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.

Accepts one of the following:
const ForwardingRuleTargetProtocolHTTP ForwardingRuleTargetProtocol = "http"
const ForwardingRuleTargetProtocolHTTPS ForwardingRuleTargetProtocol = "https"
const ForwardingRuleTargetProtocolHttp2 ForwardingRuleTargetProtocol = "http2"
const ForwardingRuleTargetProtocolTcp ForwardingRuleTargetProtocol = "tcp"
const ForwardingRuleTargetProtocolUdp ForwardingRuleTargetProtocol = "udp"
CertificateID stringoptional

The ID of the TLS certificate used for SSL termination if enabled.

TlsPassthrough booloptional

A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets.

ID stringoptional

A unique ID that can be used to identify and reference a load balancer.

formatuuid
DeprecatedAlgorithm LoadBalancerAlgorithmoptional

This field has been deprecated. You can no longer specify an algorithm for load balancers.

Accepts one of the following:
const LoadBalancerAlgorithmRoundRobin LoadBalancerAlgorithm = "round_robin"
const LoadBalancerAlgorithmLeastConnections LoadBalancerAlgorithm = "least_connections"
CreatedAt Timeoptional

A time value given in ISO8601 combined date and time format that represents when the load balancer was created.

formatdate-time
DisableLetsEncryptDNSRecords booloptional

A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer.

Domains []Domainsoptional

An array of objects specifying the domain configurations for a Global load balancer.

CertificateID stringoptional

The ID of the TLS certificate used for SSL termination.

IsManaged booloptional

A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added.

Name stringoptional

FQDN to associate with a Global load balancer.

DropletIDs []int64optional

An array containing the IDs of the Droplets assigned to the load balancer.

EnableBackendKeepalive booloptional

A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets.

EnableProxyProtocol booloptional

A boolean value indicating whether PROXY Protocol is in use.

Firewall LbFirewalloptional

An object specifying allow and deny rules to control traffic to the load balancer.

Allow []stringoptional

the rules for allowing traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16')

Deny []stringoptional

the rules for denying traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16')

GlbSettings GlbSettingsoptional

An object specifying forwarding configurations for a Global load balancer.

Cdn GlbSettingsCdnoptional

An object specifying CDN configurations for a Global load balancer.

IsEnabled booloptional

A boolean flag to enable CDN caching.

FailoverThreshold int64optional

An integer value as a percentage to indicate failure threshold to decide how the regional priorities will take effect. A value of 50 would indicate that the Global load balancer will choose a lower priority region to forward traffic to once this failure threshold has been reached for the higher priority region.

RegionPriorities map[string, int64]optional

A map of region string to an integer priority value indicating preference for which regional target a Global load balancer will forward traffic to. A lower value indicates a higher priority.

TargetPort int64optional

An integer representing the port on the target backends which the load balancer will forward traffic to.

TargetProtocol GlbSettingsTargetProtocoloptional

The protocol used for forwarding traffic from the load balancer to the target backends. The possible values are http, https and http2.

Accepts one of the following:
const GlbSettingsTargetProtocolHTTP GlbSettingsTargetProtocol = "http"
const GlbSettingsTargetProtocolHTTPS GlbSettingsTargetProtocol = "https"
const GlbSettingsTargetProtocolHttp2 GlbSettingsTargetProtocol = "http2"
HealthCheck HealthCheckoptional

An object specifying health check settings for the load balancer.

CheckIntervalSeconds int64optional

The number of seconds between between two consecutive health checks.

HealthyThreshold int64optional

The number of times a health check must pass for a backend Droplet to be marked "healthy" and be re-added to the pool.

Path stringoptional

The path on the backend Droplets to which the load balancer instance will send a request.

Port int64optional

An integer representing the port on the backend Droplets on which the health check will attempt a connection.

Protocol HealthCheckProtocoloptional

The protocol used for health checks sent to the backend Droplets. The possible values are http, https, or tcp.

Accepts one of the following:
const HealthCheckProtocolHTTP HealthCheckProtocol = "http"
const HealthCheckProtocolHTTPS HealthCheckProtocol = "https"
const HealthCheckProtocolTcp HealthCheckProtocol = "tcp"
ResponseTimeoutSeconds int64optional

The number of seconds the load balancer instance will wait for a response until marking a health check as failed.

UnhealthyThreshold int64optional

The number of times a health check must fail for a backend Droplet to be marked "unhealthy" and be removed from the pool.

HTTPIdleTimeoutSeconds int64optional

An integer value which configures the idle timeout for HTTP requests to the target droplets.

minimum30
maximum600
IP stringoptional

An attribute containing the public-facing IP address of the load balancer.

Ipv6 stringoptional

An attribute containing the public-facing IPv6 address of the load balancer.

Name stringoptional

A human-readable name for a load balancer instance.

Network LoadBalancerNetworkoptional

A string indicating whether the load balancer should be external or internal. Internal load balancers have no public IPs and are only accessible to resources on the same VPC network. This property cannot be updated after creating the load balancer.

Accepts one of the following:
const LoadBalancerNetworkExternal LoadBalancerNetwork = "EXTERNAL"
const LoadBalancerNetworkInternal LoadBalancerNetwork = "INTERNAL"
NetworkStack LoadBalancerNetworkStackoptional

A string indicating whether the load balancer will support IPv4 or both IPv4 and IPv6 networking. This property cannot be updated after creating the load balancer.

Accepts one of the following:
const LoadBalancerNetworkStackIpv4 LoadBalancerNetworkStack = "IPV4"
const LoadBalancerNetworkStackDualstack LoadBalancerNetworkStack = "DUALSTACK"
ProjectID stringoptional

The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. If an invalid project ID is provided, the load balancer will not be created.

RedirectHTTPToHTTPS booloptional

A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443.

Region Regionoptional

The region where the load balancer instance is located. When setting a region, the value should be the slug identifier for the region. When you query a load balancer, an entire region object will be returned.

Available bool

This is a boolean value that represents whether new Droplets can be created in this region.

Features []string

This attribute is set to an array which contains features available in this region

Name string

The display name of the region. This will be a full name that is used in the control panel and other interfaces.

Sizes []string

This attribute is set to an array which contains the identifying slugs for the sizes available in this region. sizes:read is required to view.

Slug string

A human-readable string that is used as a unique identifier for each region.

DeprecatedSize LoadBalancerSizeoptional

This field has been replaced by the size_unit field for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes.

  • lb-small = 1 node
  • lb-medium = 3 nodes
  • lb-large = 6 nodes

You can resize load balancers after creation up to once per hour. You cannot resize a load balancer within the first hour of its creation.

Accepts one of the following:
const LoadBalancerSizeLbSmall LoadBalancerSize = "lb-small"
const LoadBalancerSizeLbMedium LoadBalancerSize = "lb-medium"
const LoadBalancerSizeLbLarge LoadBalancerSize = "lb-large"
SizeUnit int64optional

How many nodes the load balancer contains. Each additional node increases the load balancer's ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the size field to scale load balancers that reside in these regions.

minimum1
maximum100
Status LoadBalancerStatusoptional

A status string indicating the current state of the load balancer. This can be new, active, or errored.

Accepts one of the following:
const LoadBalancerStatusNew LoadBalancerStatus = "new"
const LoadBalancerStatusActive LoadBalancerStatus = "active"
const LoadBalancerStatusErrored LoadBalancerStatus = "errored"
StickySessions StickySessionsoptional

An object specifying sticky sessions settings for the load balancer.

Type StickySessionsTypeoptional

An attribute indicating how and if requests from a client will be persistently served by the same backend Droplet. The possible values are cookies or none.

Accepts one of the following:
const StickySessionsTypeCookies StickySessionsType = "cookies"
const StickySessionsTypeNone StickySessionsType = "none"
Tag stringoptional

The name of a Droplet tag corresponding to Droplets assigned to the load balancer.

TargetLoadBalancerIDs []stringoptional

An array containing the UUIDs of the Regional load balancers to be used as target backends for a Global load balancer.

TlsCipherPolicy LoadBalancerTlsCipherPolicyoptional

A string indicating the policy for the TLS cipher suites used by the load balancer. The possible values are DEFAULT or STRONG. The default value is DEFAULT.

Accepts one of the following:
const LoadBalancerTlsCipherPolicyDefault LoadBalancerTlsCipherPolicy = "DEFAULT"
const LoadBalancerTlsCipherPolicyStrong LoadBalancerTlsCipherPolicy = "STRONG"
Type LoadBalancerTypeoptional

A string indicating whether the load balancer should be a standard regional HTTP load balancer, a regional network load balancer that routes traffic at the TCP/UDP transport layer, or a global load balancer.

Accepts one of the following:
const LoadBalancerTypeRegional LoadBalancerType = "REGIONAL"
const LoadBalancerTypeRegionalNetwork LoadBalancerType = "REGIONAL_NETWORK"
const LoadBalancerTypeGlobal LoadBalancerType = "GLOBAL"
VpcUuid stringoptional

A string specifying the UUID of the VPC to which the load balancer is assigned.

formatuuid
type StickySessions struct{…}

An object specifying sticky sessions settings for the load balancer.

Type StickySessionsTypeoptional

An attribute indicating how and if requests from a client will be persistently served by the same backend Droplet. The possible values are cookies or none.

Accepts one of the following:
const StickySessionsTypeCookies StickySessionsType = "cookies"
const StickySessionsTypeNone StickySessionsType = "none"

Load BalancersDroplets

Add Droplets to a Load Balancer
client.GPUDroplets.LoadBalancers.Droplets.Add(ctx, lbID, body) error
post/v2/load_balancers/{lb_id}/droplets
Remove Droplets from a Load Balancer
client.GPUDroplets.LoadBalancers.Droplets.Remove(ctx, lbID, body) error
delete/v2/load_balancers/{lb_id}/droplets

Load BalancersForwarding Rules

Add Forwarding Rules to a Load Balancer
client.GPUDroplets.LoadBalancers.ForwardingRules.Add(ctx, lbID, body) error
post/v2/load_balancers/{lb_id}/forwarding_rules
Remove Forwarding Rules from a Load Balancer
client.GPUDroplets.LoadBalancers.ForwardingRules.Remove(ctx, lbID, body) error
delete/v2/load_balancers/{lb_id}/forwarding_rules