I have Kubernetes running on Azure, and it uses a load balancer. Azure has assigned a public IP address to this load balancer, and for the purposes of setting up an Application Gateway via the Azure CLI I wish to obtain the IP address of the k8s load balancer using the Azure CLI.
I can obtain the load balancer resource using...
az resource list --resource-group $k8sResourceGroup --query "[?type=='Microsoft.Network/loadBalancers']"
I obtain the id
from that response and pass it to...
az network lb show --id $loadBalancer.id --output json | convertfrom-json).frontendIpConfigurations
The frontendIpConfigurations
array contains two objects: an inbound IP address (resource) and an outbound IP address (resource). I filter down to the inbound IP resource like this...
az network lb show --id $loadBalancer.id --output json | convertfrom-json).frontendIpConfigurations | where-object { $null -ne $_.loadBalancingRules }).loadBalancingRules[0].id
I then have something which looks a lot like the IP address resource's ID - it matches that which I see in the Azure portal. But if I then request the resource itself, using...
az network public-ip show --ids $loadBalancingRuleId --query "{fqdn: dnsSettings.fqdn, address: ipAddress}"
...I get...
ResourceNotFoundError: The Resource 'Microsoft.Network/publicIPAddresses/kubernetes' under resource group '[my resource group name]' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Is there a straightforward method of obtaining an AKS load balancer's public inbound IP address?