Merge pull request #12373 from justinsb/gce_no_utility_subnets

GCE: Don't create utility subnets in private topology
This commit is contained in:
Kubernetes Prow Robot 2021-09-20 15:32:23 -07:00 committed by GitHub
commit 06924c58b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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{}