in pkg/controllers/member/serviceexport/controller.go [407:427]
func (r *Reconciler) lookupPublicIPResourceIDByLoadBalancerIP(ctx context.Context, service *corev1.Service) (*armnetwork.PublicIPAddress, error) {
// The customer can specify the resource group for the public IP address in the service annotation.
rg := strings.TrimSpace(service.Annotations[objectmeta.ServiceAnnotationLoadBalancerResourceGroup])
if len(rg) == 0 {
rg = r.ResourceGroupName
}
serviceKObj := klog.KObj(service)
pips, err := r.AzurePublicIPAddressClient.List(ctx, rg)
if err != nil {
klog.ErrorS(err, "Failed to list Azure public IP addresses", "service", serviceKObj, "resourceGroup", rg)
return nil, err
}
for _, pip := range pips {
if pip.Properties != nil && pip.Properties.IPAddress != nil &&
*pip.Properties.IPAddress == service.Status.LoadBalancer.Ingress[0].IP {
return pip, nil
}
}
klog.V(2).InfoS("The public IP address resource ID cannot be found in the public IP lists", "service", serviceKObj, "ip", service.Status.LoadBalancer.Ingress[0].IP, "resourceGroup", rg)
return nil, nil
}