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
region: us-test1
type: Private
- name: utility-us-test1
region: us-test1
type: Utility
topology:
bastion:
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
}
var utilitySubnets []api.ClusterSubnetSpec
var zoneToSubnetProviderID map[string]string
var err error
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 {
if s.Type == api.SubnetTypeUtility {
continue
}
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)
addUtilitySubnets := true
switch api.CloudProviderID(cluster.Spec.CloudProvider) {
case api.CloudProviderGCE:
// GCE does not need utility subnets
addUtilitySubnets = false
}
if addUtilitySubnets {
var utilitySubnets []api.ClusterSubnetSpec
for _, s := range cluster.Spec.Subnets {
if s.Type == api.SubnetTypeUtility {
continue
}
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 {
bastionGroup := &api.InstanceGroup{}