Skip to content

Commit 51f6e1a

Browse files
committed
azure: Implement zone-redundant load balancer support
Implement the service layer changes to support zone-redundant load balancers: - Update LBSpec to include AvailabilityZones field - Modify getFrontendIPConfigs to set zones on frontend IP configurations - Update all four load balancer specs in cluster scope to pass zones: - APIServerLB - NodeOutboundLB - ControlPlaneOutboundLB - ControlPlaneInternalLB Zones are converted from []string to []*string for Azure SDK compatibility and applied to frontend IP configurations for zone redundancy.
1 parent e7a0f54 commit 51f6e1a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

azure/scope/cluster.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
267267
IdleTimeoutInMinutes: s.APIServerLB().IdleTimeoutInMinutes,
268268
AdditionalTags: s.AdditionalTags(),
269269
AdditionalPorts: s.AdditionalAPIServerLBPorts(),
270+
AvailabilityZones: s.APIServerLB().AvailabilityZones,
270271
}
271272

272273
if s.APIServerLB().FrontendIPs != nil {
@@ -301,6 +302,7 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
301302
IdleTimeoutInMinutes: s.APIServerLB().IdleTimeoutInMinutes,
302303
AdditionalTags: s.AdditionalTags(),
303304
AdditionalPorts: s.AdditionalAPIServerLBPorts(),
305+
AvailabilityZones: s.APIServerLB().AvailabilityZones,
304306
}
305307

306308
privateIPFound := false
@@ -348,6 +350,7 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
348350
IdleTimeoutInMinutes: s.NodeOutboundLB().IdleTimeoutInMinutes,
349351
Role: infrav1.NodeOutboundRole,
350352
AdditionalTags: s.AdditionalTags(),
353+
AvailabilityZones: s.NodeOutboundLB().AvailabilityZones,
351354
})
352355
}
353356

@@ -369,6 +372,7 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
369372
IdleTimeoutInMinutes: s.ControlPlaneOutboundLB().IdleTimeoutInMinutes,
370373
Role: infrav1.ControlPlaneOutboundRole,
371374
AdditionalTags: s.AdditionalTags(),
375+
AvailabilityZones: s.ControlPlaneOutboundLB().AvailabilityZones,
372376
})
373377
}
374378

azure/services/loadbalancers/spec.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type LBSpec struct {
4848
IdleTimeoutInMinutes *int32
4949
AdditionalTags map[string]string
5050
AdditionalPorts []infrav1.LoadBalancerPort
51+
AvailabilityZones []string
5152
}
5253

5354
// ResourceName returns the name of the load balancer.
@@ -167,6 +168,16 @@ func (s *LBSpec) Parameters(_ context.Context, existing interface{}) (parameters
167168
func getFrontendIPConfigs(lbSpec LBSpec) ([]*armnetwork.FrontendIPConfiguration, []*armnetwork.SubResource) {
168169
frontendIPConfigurations := make([]*armnetwork.FrontendIPConfiguration, 0)
169170
frontendIDs := make([]*armnetwork.SubResource, 0)
171+
172+
// Convert availability zones to []*string for Azure SDK
173+
var zones []*string
174+
if len(lbSpec.AvailabilityZones) > 0 {
175+
zones = make([]*string, len(lbSpec.AvailabilityZones))
176+
for i, zone := range lbSpec.AvailabilityZones {
177+
zones[i] = ptr.To(zone)
178+
}
179+
}
180+
170181
for _, ipConfig := range lbSpec.FrontendIPConfigs {
171182
var properties armnetwork.FrontendIPConfigurationPropertiesFormat
172183
if lbSpec.Type == infrav1.Internal {
@@ -187,6 +198,7 @@ func getFrontendIPConfigs(lbSpec LBSpec) ([]*armnetwork.FrontendIPConfiguration,
187198
frontendIPConfigurations = append(frontendIPConfigurations, &armnetwork.FrontendIPConfiguration{
188199
Properties: &properties,
189200
Name: ptr.To(ipConfig.Name),
201+
Zones: zones,
190202
})
191203
frontendIDs = append(frontendIDs, &armnetwork.SubResource{
192204
ID: ptr.To(azure.FrontendIPConfigID(lbSpec.SubscriptionID, lbSpec.ResourceGroup, lbSpec.Name, ipConfig.Name)),

0 commit comments

Comments
 (0)