Skip to content

Commit 2c4eaa6

Browse files
authored
Merge pull request #5738 from rna-afk/nat_gateway_zone_support
Allow users to set the zone for NAT gateway
2 parents ed22c64 + 8a11209 commit 2c4eaa6

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

api/v1beta1/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ type NatGateway struct {
259259
// +optional
260260
NatGatewayIP PublicIPSpec `json:"ip,omitempty"`
261261

262+
// Zones mentions the list of zones the NAT gateway should be a part of.
263+
// +optional
264+
Zones []string `json:"zones,omitempty"`
265+
262266
NatGatewayClassSpec `json:",inline"`
263267
}
264268

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

azure/scope/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ func (s *ClusterScope) NatGatewaySpecs() []azure.ASOResourceSpecGetter[*asonetwo
409409
SubscriptionID: s.SubscriptionID(),
410410
Location: s.Location(),
411411
ClusterName: s.ClusterName(),
412+
Zones: subnet.NatGateway.Zones,
412413
NatGatewayIP: infrav1.PublicIPSpec{
413414
Name: subnet.NatGateway.NatGatewayIP.Name,
414415
},

azure/services/natgateways/spec.go

Lines changed: 2 additions & 1 deletion
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,7 +80,7 @@ func (s *NatGatewaySpec) Parameters(_ context.Context, existingNatGateway *asone
7980
Name: ptr.To(s.Name),
8081
Additional: s.AdditionalTags,
8182
})
82-
83+
natGateway.Spec.Zones = s.Zones
8384
return natGateway, nil
8485
}
8586

azure/services/natgateways/spec_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
ResourceGroup: "my-rg",
3636
SubscriptionID: "123",
3737
Location: "eastus",
38+
Zones: []string{"eastus-1"},
3839
NatGatewayIP: infrav1.PublicIPSpec{
3940
Name: "my-natgateway-ip",
4041
DNSName: "Standard",
@@ -58,6 +59,7 @@ var (
5859
AzureName: "my-natgateway",
5960
IdleTimeoutInMinutes: ptr.To(6),
6061
Location: locationPtr,
62+
Zones: []string{"eastus-1"},
6163
Owner: &genruntime.KnownResourceReference{
6264
Name: "my-rg",
6365
},
@@ -113,6 +115,8 @@ func TestParameters(t *testing.T) {
113115
g.Expect(parameters.Spec.Owner.Name).To(Equal("my-rg"))
114116
g.Expect(parameters.Spec.Location).NotTo(BeNil())
115117
g.Expect(parameters.Spec.Location).To(Equal(locationPtr))
118+
g.Expect(parameters.Spec.Zones).To(HaveLen(1))
119+
g.Expect(parameters.Spec.Zones[0]).To(Equal("eastus-1"))
116120
g.Expect(parameters.Spec.Sku.Name).NotTo(BeNil())
117121
g.Expect(parameters.Spec.Sku.Name).To(Equal(standardSKUPtr))
118122
g.Expect(parameters.Spec.PublicIpAddresses).To(HaveLen(1))

config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ spec:
215215
type: object
216216
name:
217217
type: string
218+
zones:
219+
description: Zones mentions the list of zones the
220+
NAT gateway should be a part of.
221+
items:
222+
type: string
223+
type: array
218224
required:
219225
- name
220226
type: object
@@ -1003,6 +1009,12 @@ spec:
10031009
type: object
10041010
name:
10051011
type: string
1012+
zones:
1013+
description: Zones mentions the list of zones the NAT
1014+
gateway should be a part of.
1015+
items:
1016+
type: string
1017+
type: array
10061018
required:
10071019
- name
10081020
type: object

0 commit comments

Comments
 (0)