12

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 Answers 2

12

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

1
  • This is great to know since it's not clear why so many resources are used to setup load balancing. Do you know how to add delete protection to all of those resources so you do not accidently delete a load balancer?
    – Drew
    Jul 29, 2021 at 18:16
10

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).

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.