Skip to content
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

[release-1.10] fix vnet in separate resource group #4207

Merged
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: 2 additions & 2 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (s *ClusterScope) RouteTableSpecs() []azure.ResourceSpecGetter {
specs = append(specs, &routetables.RouteTableSpec{
Name: subnet.RouteTable.Name,
Location: s.Location(),
ResourceGroup: s.ResourceGroup(),
ResourceGroup: s.Vnet().ResourceGroup,
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
})
Expand Down Expand Up @@ -360,7 +360,7 @@ func (s *ClusterScope) NSGSpecs() []azure.ResourceSpecGetter {
nsgspecs[i] = &securitygroups.NSGSpec{
Name: subnet.SecurityGroup.Name,
SecurityRules: subnet.SecurityGroup.SecurityRules,
ResourceGroup: s.ResourceGroup(),
ResourceGroup: s.Vnet().ResourceGroup,
Location: s.Location(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
Expand Down
8 changes: 6 additions & 2 deletions azure/scope/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,13 @@ func TestRouteTableSpecs(t *testing.T) {
},
AzureCluster: &infrav1.AzureCluster{
Spec: infrav1.AzureClusterSpec{
ResourceGroup: "my-rg",
AzureClusterClassSpec: infrav1.AzureClusterClassSpec{
Location: "centralIndia",
},
NetworkSpec: infrav1.NetworkSpec{
Vnet: infrav1.VnetSpec{
ResourceGroup: "my-rg",
},
Subnets: infrav1.Subnets{
{
RouteTable: infrav1.RouteTable{
Expand Down Expand Up @@ -1140,11 +1142,13 @@ func TestNSGSpecs(t *testing.T) {
},
AzureCluster: &infrav1.AzureCluster{
Spec: infrav1.AzureClusterSpec{
ResourceGroup: "my-rg",
AzureClusterClassSpec: infrav1.AzureClusterClassSpec{
Location: "centralIndia",
},
NetworkSpec: infrav1.NetworkSpec{
Vnet: infrav1.VnetSpec{
ResourceGroup: "my-rg",
},
Subnets: infrav1.Subnets{
{
SecurityGroup: infrav1.SecurityGroup{
Expand Down
2 changes: 1 addition & 1 deletion templates/test/ci/cluster-template-prow-custom-vnet.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/test/ci/cluster-template-prow-private.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
networkSpec:
vnet:
resourceGroup: ${AZURE_RESOURCE_GROUP}
resourceGroup: ${AZURE_CUSTOM_VNET_RESOURCE_GROUP}
name: ${AZURE_CUSTOM_VNET_NAME}
subnets:
- name: ${AZURE_CUSTOM_VNET_NAME}-controlplane-subnet
Expand Down
2 changes: 1 addition & 1 deletion templates/test/ci/prow-private/patches/vnet-peerings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
cidrBlocks:
- ${AZURE_PRIVATE_VNET_CIDR}
peerings:
- resourceGroup: ${AZURE_RESOURCE_GROUP}
- resourceGroup: ${AZURE_CUSTOM_VNET_RESOURCE_GROUP}
remoteVnetName: ${AZURE_CUSTOM_VNET_NAME}
subnets:
- name: private-cp-subnet
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/azure_privatecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func SetupExistingVNet(ctx context.Context, vnetCidr string, cpSubnetCidrs, node
routetableClient.Authorizer = authorizer

By("creating a resource group")
groupName := os.Getenv(AzureResourceGroup)
groupName := os.Getenv(AzureCustomVnetResourceGroup)
_, err = groupClient.CreateOrUpdate(ctx, groupName, resources.Group{
Location: pointer.String(os.Getenv(AzureLocation)),
Tags: map[string]*string{
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var _ = Describe("Workload cluster creation", func() {
}
dumpSpecResourcesAndCleanup(ctx, cleanInput)
Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed())
Expect(os.Unsetenv(AzureCustomVnetResourceGroup)).To(Succeed())
Expect(os.Unsetenv(AzureVNetName)).To(Succeed())
Expect(os.Unsetenv(ClusterIdentityName)).To(Succeed())
Expect(os.Unsetenv(ClusterIdentityNamespace)).To(Succeed())
Expand All @@ -155,6 +156,7 @@ var _ = Describe("Workload cluster creation", func() {
clusterName = getClusterName(clusterNamePrefix, "public-custom-vnet")
By("Creating a custom virtual network", func() {
Expect(os.Setenv(AzureCustomVNetName, "custom-vnet")).To(Succeed())
Expect(os.Setenv(AzureCustomVnetResourceGroup, clusterName+"-vnetrg")).To(Succeed())
additionalCleanup = SetupExistingVNet(ctx,
"10.0.0.0/16",
map[string]string{fmt.Sprintf("%s-controlplane-subnet", os.Getenv(AzureCustomVNetName)): "10.0.0.0/24"},
Expand Down
1 change: 1 addition & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
AzureExtendedLocationType = "AZURE_EXTENDEDLOCATION_TYPE"
AzureExtendedLocationName = "AZURE_EXTENDEDLOCATION_NAME"
AzureResourceGroup = "AZURE_RESOURCE_GROUP"
AzureCustomVnetResourceGroup = "AZURE_CUSTOM_VNET_RESOURCE_GROUP"
AzureVNetName = "AZURE_VNET_NAME"
AzureCustomVNetName = "AZURE_CUSTOM_VNET_NAME"
AzureInternalLBIP = "AZURE_INTERNAL_LB_IP"
Expand Down