Skip to content

Commit 8a11209

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 8a11209

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
@@ -253,6 +253,10 @@ type NatGateway struct {
253253
// +optional
254254
NatGatewayIP PublicIPSpec `json:"ip,omitempty"`
255255

256+
// Zones mentions the list of zones the NAT gateway should be a part of.
257+
// +optional
258+
Zones []string `json:"zones,omitempty"`
259+
256260
NatGatewayClassSpec `json:",inline"`
257261
}
258262

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
@@ -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))

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
@@ -995,6 +1001,12 @@ spec:
9951001
type: object
9961002
name:
9971003
type: string
1004+
zones:
1005+
description: Zones mentions the list of zones the NAT
1006+
gateway should be a part of.
1007+
items:
1008+
type: string
1009+
type: array
9981010
required:
9991011
- name
10001012
type: object

0 commit comments

Comments
 (0)