Skip to content

Commit

Permalink
Merge pull request #3424 from CecileRobertMichon/natgw-pip-name
Browse files Browse the repository at this point in the history
Change default nat gateway IP name
  • Loading branch information
k8s-ci-robot authored Apr 14, 2023
2 parents eec7b71 + aeee6e1 commit d662a91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions api/v1beta1/azurecluster_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *AzureCluster) setSubnetDefaults() {
subnet.NatGateway.Name = withIndex(generateNatGatewayName(c.ObjectMeta.Name), nodeSubnetCounter)
}
if subnet.NatGateway.NatGatewayIP.Name == "" {
subnet.NatGateway.NatGatewayIP.Name = generateNatGatewayIPName(c.ObjectMeta.Name, subnet.Name)
subnet.NatGateway.NatGatewayIP.Name = generateNatGatewayIPName(subnet.NatGateway.Name)
}
}

Expand Down Expand Up @@ -453,8 +453,8 @@ func generateNatGatewayName(clusterName string) string {
}

// generateNatGatewayIPName generates a NAT gateway IP name.
func generateNatGatewayIPName(clusterName, subnetName string) string {
return fmt.Sprintf("pip-%s-%s-natgw", clusterName, subnetName)
func generateNatGatewayIPName(natGatewayName string) string {
return fmt.Sprintf("pip-%s", natGatewayName)
}

// withIndex appends the index as suffix to a generated name.
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/azurecluster_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "foo-natgw",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-my-node-subnet-natgw",
Name: "pip-foo-natgw",
},
},
},
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "cluster-test-node-natgw-1",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-cluster-test-node-subnet-natgw",
Name: "pip-cluster-test-node-natgw-1",
},
},
},
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "cluster-test-node-natgw-1",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-cluster-test-node-subnet-natgw",
Name: "pip-cluster-test-node-natgw-1",
},
},
},
Expand Down Expand Up @@ -549,7 +549,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "cluster-test-node-natgw-1",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-my-node-subnet-natgw",
Name: "pip-cluster-test-node-natgw-1",
},
},
},
Expand Down
5 changes: 0 additions & 5 deletions azure/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ func GenerateFrontendIPConfigName(lbName string) string {
return fmt.Sprintf("%s-%s", lbName, "frontEnd")
}

// GenerateNatGatewayIPName generates a NAT gateway IP name.
func GenerateNatGatewayIPName(clusterName, subnetName string) string {
return fmt.Sprintf("pip-%s-%s-natgw", clusterName, subnetName)
}

// GenerateNodeOutboundIPName generates a public IP name, based on the cluster name.
func GenerateNodeOutboundIPName(clusterName string) string {
return fmt.Sprintf("pip-%s-node-outbound", clusterName)
Expand Down

0 comments on commit d662a91

Please sign in to comment.