func (az *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
	// When a client updates the internal load balancer annotation,
	// the service may be switched from an internal LB to a public one, or vise versa.
	// Here we'll firstly ensure service do not lie in the opposite LB.
	serviceName := getServiceName(service)
	glog.V(5).Infof("ensureloadbalancer(%s): START clusterName=%q", serviceName, clusterName)
	flippedService := flipServiceInternalAnnotation(service)
	if _, err := az.reconcileLoadBalancer(clusterName, flippedService, nil, false /* wantLb */); err != nil {
		return nil, err
	}

	if _, err := az.reconcilePublicIP(clusterName, service, true /* wantLb */); err != nil {
		return nil, err
	}

	lb, err := az.reconcileLoadBalancer(clusterName, service, nodes, true /* wantLb */)
	if err != nil {
		return nil, err
	}

	lbStatus, err := az.getServiceLoadBalancerStatus(service, lb)
	if err != nil {
		return nil, err
	}

	var serviceIP *string
	if lbStatus != nil && len(lbStatus.Ingress) > 0 {
		serviceIP = &lbStatus.Ingress[0].IP
	}
	glog.V(10).Infof("Calling reconcileSecurityGroup from EnsureLoadBalancer for %s with IP %s, wantLb = true", service.Name, logSafe(serviceIP))
	if _, err := az.reconcileSecurityGroup(clusterName, service, serviceIP, true /* wantLb */); err != nil {
		return nil, err
	}

	return lbStatus, nil
}
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
// EnsureLoadBalancer creates a new load balancer ' name ' or updates the existing one . Returns the status of the balancer
func (az *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
	serviceName := getServiceName(service)
	glog.V(5).Infof("ensureloadbalancer(%s): START clusterName=%q", serviceName, clusterName)
	flippedService := flipServiceInternalAnnotation(service)
	if _, err := az.reconcileLoadBalancer(clusterName, flippedService, nil, false ); err != nil {
		return nil, err
	}
	if _, err := az.reconcilePublicIP(clusterName, service, true ); err != nil {
		return nil, err
	}
	lb, err := az.reconcileLoadBalancer(clusterName, service, nodes, true )
	if err != nil {
		return nil, err
	}
	lbStatus, err := az.getServiceLoadBalancerStatus(service, lb)
	if err != nil {
		return nil, err
	}
	var serviceIP *string
	if lbStatus != nil && len(lbStatus.Ingress) > 0 {
		serviceIP = &lbStatus.Ingress[0].IP
	}
	glog.V(10).Infof("Calling reconcileSecurityGroup from EnsureLoadBalancer for %s with IP %s, wantLb = true", service.Name, logSafe(serviceIP))
	if _, err := az.reconcileSecurityGroup(clusterName, service, serviceIP, true ); err != nil {
		return nil, err
	}
	return lbStatus, nil
}
func ( az * Cloud ) EnsureLoadBalancer ( ctx context . Context , clusterName string , service * v1 . Service , nodes [ ] * v1 . Node ) ( * v1 . LoadBalancerStatus , error ) { serviceName := getServiceName ( service ) glog . V ( 5 ) . Infof ( " " , serviceName , clusterName ) flippedService := flipServiceInternalAnnotation ( service ) if _ , err := az . reconcileLoadBalancer ( clusterName , flippedService , nil , false ) ; err != nil { return nil , err } if _ , err := az . reconcilePublicIP ( clusterName , service , true ) ; err != nil { return nil , err } lb , err := az . reconcileLoadBalancer ( clusterName , service , nodes , true ) if err != nil { return nil , err } lbStatus , err := az . getServiceLoadBalancerStatus ( service , lb ) if err != nil { return nil , err } var serviceIP * string if lbStatus != nil && len ( lbStatus . Ingress ) > 0 { serviceIP = & lbStatus . Ingress [ 0 ] . IP } glog . V ( 10 ) . Infof ( " " , service . Name , logSafe ( serviceIP ) ) if _ , err := az . reconcileSecurityGroup ( clusterName , service , serviceIP , true ) ; err != nil { return nil , err } return lbStatus , nil }
EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one.
EnsureLoadBalancer creates a new load balancer ' name ' or updates the existing one .
// When a client updates the internal load balancer annotation, // the service may be switched from an internal LB to a public one, or vise versa. // Here we'll firstly ensure service do not lie in the opposite LB. /* wantLb */ /* wantLb */ /* wantLb */ /* wantLb */