9
votes

From GCP portal perspective Load balancer is a service and related services comes under it like backendServers, health Check etc.

However APIs are only available for services like backendService, address, healthcheck etc.

Using UI we could find direct relationship between service like backendServers and LoadBalancer but backend service API doesn't have respective field.

While on UI we have: enter image description here

Where as supported fields from backend service: affinityCookieTtlSec,backends,cdnPolicy,connectionDraining,creationTimestamp,description,enableCDN,fingerprint,healthChecks,iap,id,kind,loadBalancingScheme,name,port,portName,protocol,region,selfLink,sessionAffinity,timeoutSec

Wanted to know if there is direct / indirect way to get List of Load Balancers

2

2 Answers

9
votes

As mentioned by Patrick W, there is no direct entity 'load balancer', its just a collection of components. The list seen in the UI that appears to be the load balancer is actually the url-map component, which can be seen via the API with:

gcloud compute url-maps list

More information on the command

6
votes

At the API level, there is no Load Balancer, only the components that make it up. Your best bet to get a view similar to the UI is to list forwarding rules (global and regional). You can use gcloud compute forwarding-rules list which will show you all the forwarding rules in use (similar to the UI view), along with the IPs of each and the target (which may be a backend service or a target pool).