Skip to content

Commit

Permalink
add formation flow for clb lb rules
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeedward2000 committed Feb 18, 2025
1 parent 4cc9f2b commit f52242e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/provider/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,36 @@ func (az *Cloud) getExpectedLBRules(
isIPv6 bool,
) ([]*armnetwork.Probe, []*armnetwork.LoadBalancingRule, error) {
var expectedRules []*armnetwork.LoadBalancingRule
// If we are using Pod IP in the LB backend, we skip health probes, disable floating IP and use port.TargetPort.
if az.IsLBBackendPoolTypePodIP() {
// Check for multi-IP families in the service spec (not allowed for CLB).
if len(service.Spec.IPFamilies) > 1 {
return nil, nil, fmt.Errorf("dual-stack services are not supported when LB backend pool type is PodIP")
}
// Build rules for each service port but with floatingIP = false, no health probes.
for _, port := range service.Spec.Ports {
ruleName := az.getLoadBalancerRuleName(service, port.Protocol, port.Port, isIPv6)
transportProto, _, _, err := getProtocolsFromKubernetesProtocol(port.Protocol)
if err != nil {
return nil, nil, fmt.Errorf("failed to parse transport protocol: %w", err)
}
props, err := az.getExpectedLoadBalancingRulePropertiesForPort(service, lbFrontendIPConfigID, lbBackendPoolID, port, transportProto)
if err != nil {
return nil, nil, fmt.Errorf("error generating LB rule: %w", err)
}
// Turn off floating IP and skip health probe attachments.
props.EnableFloatingIP = ptr.To(false)
props.Probe = nil
props.BackendPort = ptr.To(int32(port.TargetPort.IntValue()))
expectedRules = append(expectedRules, &armnetwork.LoadBalancingRule{
Name: &ruleName,
Properties: props,
})
}
return nil, expectedRules, nil
}

// Otherwise, the existing flow remains unchanged
var expectedProbes []*armnetwork.Probe

// support podPresence health check when External Traffic Policy is local
Expand Down
4 changes: 4 additions & 0 deletions pkg/provider/config/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ func (az *Config) IsLBBackendPoolTypeNodeIP() bool {
return strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeNodeIP)
}

func (az *Config) IsLBBackendPoolTypePodIP() bool {
return strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypePodIP)
}

func (az *Config) GetPutVMSSVMBatchSize() int {
return az.PutVMSSVMBatchSize
}
Expand Down

0 comments on commit f52242e

Please sign in to comment.