Skip to content

Allow users to set the zone for NAT gateway #5738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions azure/services/natgateways/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type NatGatewaySpec struct {
Location string
NatGatewayIP infrav1.PublicIPSpec
ClusterName string
Zone string
AdditionalTags infrav1.Tags
IsVnetManaged bool
}
Expand Down Expand Up @@ -79,6 +80,9 @@ func (s *NatGatewaySpec) Parameters(_ context.Context, existingNatGateway *asone
Name: ptr.To(s.Name),
Additional: s.AdditionalTags,
})
if s.Zone != "" {
natGateway.Spec.Zones = []string{s.Zone}
}

return natGateway, nil
}
Expand Down
4 changes: 4 additions & 0 deletions azure/services/natgateways/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
ResourceGroup: "my-rg",
SubscriptionID: "123",
Location: "eastus",
Zone: "eastus-1",
NatGatewayIP: infrav1.PublicIPSpec{
Name: "my-natgateway-ip",
DNSName: "Standard",
Expand All @@ -59,6 +60,7 @@ var (
AzureName: "my-natgateway",
IdleTimeoutInMinutes: ptr.To(6),
Location: locationPtr,
Zones: []string{"eastus-1"},
Owner: &genruntime.KnownResourceReference{
Name: "my-rg",
},
Expand Down Expand Up @@ -114,6 +116,8 @@ func TestParameters(t *testing.T) {
g.Expect(parameters.Spec.Owner.Name).To(Equal("my-rg"))
g.Expect(parameters.Spec.Location).NotTo(BeNil())
g.Expect(parameters.Spec.Location).To(Equal(locationPtr))
g.Expect(parameters.Spec.Zones).To(HaveLen(1))
g.Expect(parameters.Spec.Zones[0]).To(Equal("eastus-1"))
g.Expect(parameters.Spec.Sku.Name).NotTo(BeNil())
g.Expect(parameters.Spec.Sku.Name).To(Equal(standardSKUPtr))
g.Expect(parameters.Spec.PublicIpAddresses).To(HaveLen(1))
Expand Down
Loading