GCE: Don't create utility subnets in private topology

We don't need them on GCE, and in fact we don't support them with IP Alias.
This commit is contained in:
justinsb 2021-09-19 19:09:17 -04:00
parent 8b9f4ec41c
commit 16fc5e8cec
2 changed files with 26 additions and 20 deletions

View File

@ -52,9 +52,6 @@ spec:
- name: us-test1 - name: us-test1
region: us-test1 region: us-test1
type: Private type: Private
- name: utility-us-test1
region: us-test1
type: Utility
topology: topology:
bastion: bastion:
bastionPublicName: bastion.private.example.com bastionPublicName: bastion.private.example.com

View File

@ -980,8 +980,6 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S
cluster.Spec.Subnets[i].Type = api.SubnetTypePrivate cluster.Spec.Subnets[i].Type = api.SubnetTypePrivate
} }
var utilitySubnets []api.ClusterSubnetSpec
var zoneToSubnetProviderID map[string]string var zoneToSubnetProviderID map[string]string
var err error var err error
if len(opt.Zones) > 0 && len(opt.UtilitySubnetIDs) > 0 { if len(opt.Zones) > 0 && len(opt.UtilitySubnetIDs) > 0 {
@ -1001,22 +999,33 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S
} }
} }
for _, s := range cluster.Spec.Subnets { addUtilitySubnets := true
if s.Type == api.SubnetTypeUtility { switch api.CloudProviderID(cluster.Spec.CloudProvider) {
continue case api.CloudProviderGCE:
} // GCE does not need utility subnets
subnet := api.ClusterSubnetSpec{ addUtilitySubnets = false
Name: "utility-" + s.Name, }
Zone: s.Zone,
Type: api.SubnetTypeUtility, if addUtilitySubnets {
Region: s.Region, var utilitySubnets []api.ClusterSubnetSpec
}
if subnetID, ok := zoneToSubnetProviderID[s.Zone]; ok { for _, s := range cluster.Spec.Subnets {
subnet.ProviderID = subnetID if s.Type == api.SubnetTypeUtility {
} continue
utilitySubnets = append(utilitySubnets, subnet) }
subnet := api.ClusterSubnetSpec{
Name: "utility-" + s.Name,
Zone: s.Zone,
Type: api.SubnetTypeUtility,
Region: s.Region,
}
if subnetID, ok := zoneToSubnetProviderID[s.Zone]; ok {
subnet.ProviderID = subnetID
}
utilitySubnets = append(utilitySubnets, subnet)
}
cluster.Spec.Subnets = append(cluster.Spec.Subnets, utilitySubnets...)
} }
cluster.Spec.Subnets = append(cluster.Spec.Subnets, utilitySubnets...)
if opt.Bastion { if opt.Bastion {
bastionGroup := &api.InstanceGroup{} bastionGroup := &api.InstanceGroup{}