New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support attaching node private IP to the load balancer backendpools #918
Conversation
// LoadBalancerBackendPoolConfigurationTypeVMIP is the lb backend pool config type vm ip | ||
LoadBalancerBackendPoolConfigurationTypeVMIP = "vmIP" | ||
// LoadBalancerBackendPoolConfigurationTypePODIP is the lb backend pool config type pod ip | ||
LoadBalancerBackendPoolConfigurationTypePODIP = "podIP" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is PodIP support added in this PR? If not, please add a TODO comment to say it is not supported yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
// are `vmNIC`, `vmIP` and `podIP`. | ||
// `vmNIC`: vm network interfaces will be attached to the inbound backend pool of the load balancer (default); | ||
// `vmIP`: vm private IPs will be attached to the inbound backend pool of the load balancer; | ||
// `podIP`: pod IPs will be attached to the inbound backend pool of the load balancer (not supported yet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the full name here and rename vm to node, e.g. nodeIPConfiguration, nodeIP, podIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -496,6 +504,20 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret, callFromC | |||
} | |||
} | |||
|
|||
if config.LoadBalancerBackendPoolConfigurationType == "" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please omit the character size when comparing the values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -1037,6 +1059,15 @@ func (az *Cloud) updateNodeCaches(prevNode, newNode *v1.Node) { | |||
} | |||
} | |||
|
|||
func (az *Cloud) ListNodes(ctx context.Context) ([]v1.Node, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use the nodeInformer to cache all the Node IPs here? refer
cloud-provider-azure/pkg/provider/azure.go
Lines 971 to 1038 in be76f79
func (az *Cloud) updateNodeCaches(prevNode, newNode *v1.Node) { | |
az.nodeCachesLock.Lock() | |
defer az.nodeCachesLock.Unlock() | |
if prevNode != nil { | |
// Remove from nodeNames cache. | |
az.nodeNames.Delete(prevNode.ObjectMeta.Name) | |
// Remove from nodeZones cache. | |
prevZone, ok := prevNode.ObjectMeta.Labels[consts.LabelFailureDomainBetaZone] | |
if ok && az.isAvailabilityZone(prevZone) { | |
az.nodeZones[prevZone].Delete(prevNode.ObjectMeta.Name) | |
if az.nodeZones[prevZone].Len() == 0 { | |
az.nodeZones[prevZone] = nil | |
} | |
} | |
// Remove from nodeResourceGroups cache. | |
_, ok = prevNode.ObjectMeta.Labels[consts.ExternalResourceGroupLabel] | |
if ok { | |
delete(az.nodeResourceGroups, prevNode.ObjectMeta.Name) | |
} | |
// Remove from unmanagedNodes cache. | |
managed, ok := prevNode.ObjectMeta.Labels[consts.ManagedByAzureLabel] | |
if ok && strings.EqualFold(managed, consts.NotManagedByAzureLabelValue) { | |
az.unmanagedNodes.Delete(prevNode.ObjectMeta.Name) | |
az.excludeLoadBalancerNodes.Delete(prevNode.ObjectMeta.Name) | |
} | |
// Remove from excludeLoadBalancerNodes cache. | |
if _, hasExcludeBalancerLabel := prevNode.ObjectMeta.Labels[v1.LabelNodeExcludeBalancers]; hasExcludeBalancerLabel { | |
az.excludeLoadBalancerNodes.Delete(prevNode.ObjectMeta.Name) | |
} | |
} | |
if newNode != nil { | |
// Add to nodeNames cache. | |
az.nodeNames.Insert(newNode.ObjectMeta.Name) | |
// Add to nodeZones cache. | |
newZone, ok := newNode.ObjectMeta.Labels[consts.LabelFailureDomainBetaZone] | |
if ok && az.isAvailabilityZone(newZone) { | |
if az.nodeZones[newZone] == nil { | |
az.nodeZones[newZone] = sets.NewString() | |
} | |
az.nodeZones[newZone].Insert(newNode.ObjectMeta.Name) | |
} | |
// Add to nodeResourceGroups cache. | |
newRG, ok := newNode.ObjectMeta.Labels[consts.ExternalResourceGroupLabel] | |
if ok && len(newRG) > 0 { | |
az.nodeResourceGroups[newNode.ObjectMeta.Name] = strings.ToLower(newRG) | |
} | |
// Add to unmanagedNodes cache. | |
managed, ok := newNode.ObjectMeta.Labels[consts.ManagedByAzureLabel] | |
if ok && strings.EqualFold(managed, consts.NotManagedByAzureLabelValue) { | |
az.unmanagedNodes.Insert(newNode.ObjectMeta.Name) | |
az.excludeLoadBalancerNodes.Insert(newNode.ObjectMeta.Name) | |
} | |
// Add to excludeLoadBalancerNodes cache. | |
if _, hasExcludeBalancerLabel := newNode.ObjectMeta.Labels[v1.LabelNodeExcludeBalancers]; hasExcludeBalancerLabel { | |
az.excludeLoadBalancerNodes.Insert(newNode.ObjectMeta.Name) | |
} | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/provider/azure_backoff.go
Outdated
agentPoolVMSetNamesSet.Insert(strings.ToLower(vmSetName)) | ||
} | ||
} | ||
|
||
for _, lb := range allLBs { | ||
vmSetNameFromLBName := az.mapLoadBalancerNameToVMSet(to.String(lb.Name), clusterName) | ||
if agentPoolVMSetNamesSet.Has(strings.ToLower(vmSetNameFromLBName)) { | ||
if strings.EqualFold(to.String(lb.Name), clusterName) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this condition is this a bug even without this feature?
pkg/provider/azure_loadbalancer.go
Outdated
_, vmSetName, err := az.VMSet.GetNodeNameByIPConfigurationID(ipConfigID) | ||
if err != nil && !errors.Is(err, cloudprovider.InstanceNotFound) { | ||
if strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeVMNIC) { | ||
if bp.BackendAddressPoolPropertiesFormat != nil && bp.BackendIPConfigurations != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to get it easier to understand, could you extract the cleanup logic in L234 and L255 to separate functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/provider/azure_loadbalancer.go
Outdated
return nil, fmt.Errorf("reconcileSharedLoadBalancer: failed to list managed LB: %w", err) | ||
} | ||
} else { | ||
existingLBs, err = az.ListLB(service) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to merge this two LISTs together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged
pkg/provider/azure_loadbalancer.go
Outdated
|
||
if bp.BackendAddressPoolPropertiesFormat != nil { | ||
if strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeVMNIC) && | ||
bp.BackendIPConfigurations != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to put the backend pool implementations behind the VMSet interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a new interface LoadBalancerBackendPool
pkg/provider/azure_loadbalancer.go
Outdated
|
||
useMultipleSLBs := strings.EqualFold(az.LoadBalancerSku, "standard") && az.EnableMultipleStandardLoadBalancers | ||
if strings.EqualFold(az.LoadBalancerSku, "basic") || useMultipleSLBs { | ||
vmSetName, err := az.VMSet.GetNodeVMSetName(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you skip the standalone VM for this case? (and same for other places)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standalone VM will be skipped because az.VMSet.GetNodeVMSetName will return an empty string.
pkg/provider/azure_loadbalancer.go
Outdated
} | ||
|
||
// remove the deleted LB from the list | ||
existingLBs = append(existingLBs[:i], existingLBs[i+1:]...) | ||
} | ||
|
||
for _, primarySLB := range primarySLBs { | ||
//var updatedNodeIPs bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments. Let's get this merged and please add documents in a following PR.
/lgtm
/approve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feiskyer, nilo19, ZeroMagic The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Currently we bind the VM/VMSS to the LB by attaching their NICs to the LB which needs to call the API of VM/VMSS. This PR introduces a new config
loadBalancerBackendPoolConfigurationType
and it can be set tonodeIPConfiguration
(default) ornodeIP
. If set tonodeIPConfiguration
, everything will keep unchanged. If set tonodeIP
, the cloud provider will call the LB API to attach the node private IPs to the LB instead of linking the NICs to the LB.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: