Use Azure CLI to obtain Kubernetes Load Balancer's public IP Use Azure CLI to obtain Kubernetes Load Balancer's public IP kubernetes kubernetes

Use Azure CLI to obtain Kubernetes Load Balancer's public IP


Try this (assuming, your LB only has one inbound IP address. Otherwise $pipId is an array)

$pipId = $(az network lb show --id $loadBalancer.id --query "frontendIpConfigurations | [?loadBalancingRules != null].publicIpAddress.id" -o tsv)$ip = (az network public-ip show --ids $pipId --query "ipAddress" -o tsv)


Is there a straightforward method of obtaining an AKS load balancer'spublic inbound IP address?

All the public IPs associated with the Load Balancer of the AKS are the inbound IPs, except the outbound IP. And all the inbound IPs are the public IPs of the services in the AKS. It means if you know how many services with the load balancer type, then you will know how many public inbound IPs associated with the load balancer of the AKS.

According to this cognition, you just need to get the public IP address of the service, then you can get the resource ID of this public IP through Azure CLI:

az network public-ip list --query "[?ipAddress=='publicIPAddress'].id" -o tsv