Skip to content

Commit 5d32578

Browse files
committed
Allow users to set the zones for NAT gateway
Allow users to set the zones they need the created NAT gateway to use. ASO allows the NAT gateway to be set to a list of zones so enabling that here.
1 parent 7194cbd commit 5d32578

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

api/v1beta1/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ type NatGateway struct {
259259
// NatGatewayClassSpec defines a NAT gateway class specification.
260260
type NatGatewayClassSpec struct {
261261
Name string `json:"name"`
262+
263+
// Zones mentions the list of zones the NAT gateway should be a part of.
264+
Zones []string `json:"zones"`
262265
}
263266

264267
// SecurityGroupProtocol defines the protocol type for a security group rule.

azure/scope/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ func (s *ClusterScope) NatGatewaySpecs() []azure.ASOResourceSpecGetter[*asonetwo
412412
NatGatewayIP: infrav1.PublicIPSpec{
413413
Name: subnet.NatGateway.NatGatewayIP.Name,
414414
},
415+
Zones: subnet.NatGateway.Zones,
415416
AdditionalTags: s.AdditionalTags(),
416417
// We need to know if the VNet is managed to decide if this NAT Gateway was-managed or not.
417418
IsVnetManaged: s.IsVnetManaged(),

azure/services/natgateways/spec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type NatGatewaySpec struct {
3636
Location string
3737
NatGatewayIP infrav1.PublicIPSpec
3838
ClusterName string
39+
Zones []string
3940
AdditionalTags infrav1.Tags
4041
IsVnetManaged bool
4142
}
@@ -79,6 +80,9 @@ func (s *NatGatewaySpec) Parameters(_ context.Context, existingNatGateway *asone
7980
Name: ptr.To(s.Name),
8081
Additional: s.AdditionalTags,
8182
})
83+
if len(s.Zones) != 0 {
84+
natGateway.Spec.Zones = s.Zones
85+
}
8286

8387
return natGateway, nil
8488
}

azure/services/natgateways/spec_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var (
3636
ResourceGroup: "my-rg",
3737
SubscriptionID: "123",
3838
Location: "eastus",
39+
Zones: []string{"eastus-1"},
3940
NatGatewayIP: infrav1.PublicIPSpec{
4041
Name: "my-natgateway-ip",
4142
DNSName: "Standard",
@@ -59,6 +60,7 @@ var (
5960
AzureName: "my-natgateway",
6061
IdleTimeoutInMinutes: ptr.To(6),
6162
Location: locationPtr,
63+
Zones: []string{"eastus-1"},
6264
Owner: &genruntime.KnownResourceReference{
6365
Name: "my-rg",
6466
},
@@ -114,6 +116,8 @@ func TestParameters(t *testing.T) {
114116
g.Expect(parameters.Spec.Owner.Name).To(Equal("my-rg"))
115117
g.Expect(parameters.Spec.Location).NotTo(BeNil())
116118
g.Expect(parameters.Spec.Location).To(Equal(locationPtr))
119+
g.Expect(parameters.Spec.Zones).To(HaveLen(1))
120+
g.Expect(parameters.Spec.Zones[0]).To(Equal("eastus-1"))
117121
g.Expect(parameters.Spec.Sku.Name).NotTo(BeNil())
118122
g.Expect(parameters.Spec.Sku.Name).To(Equal(standardSKUPtr))
119123
g.Expect(parameters.Spec.PublicIpAddresses).To(HaveLen(1))

0 commit comments

Comments
 (0)