Reduce use of cluster topology field

This commit is contained in:
John Gardiner Myers 2022-12-30 13:07:57 -08:00
parent fc527b6e9f
commit 1be8be233f
3 changed files with 9 additions and 6 deletions

View File

@ -217,9 +217,14 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {
infoByZone := make(map[string]*zoneInfo) infoByZone := make(map[string]*zoneInfo)
haveDualStack := map[string]bool{} haveDualStack := map[string]bool{}
haveAnyPrivate := false
for _, subnetSpec := range b.Cluster.Spec.Networking.Subnets { for _, subnetSpec := range b.Cluster.Spec.Networking.Subnets {
if subnetSpec.Type == kops.SubnetTypeDualStack { switch subnetSpec.Type {
case kops.SubnetTypeDualStack:
haveDualStack[subnetSpec.Zone] = true haveDualStack[subnetSpec.Zone] = true
haveAnyPrivate = true
case kops.SubnetTypePrivate:
haveAnyPrivate = true
} }
} }
@ -240,8 +245,8 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {
tags[aws.TagNameSubnetPublicELB] = "1" tags[aws.TagNameSubnetPublicELB] = "1"
// AWS ALB contoller won't provision any internal ELBs unless this tag is set. // AWS ALB contoller won't provision any internal ELBs unless this tag is set.
// So we add this to public subnets as well if we do not expect any private subnets. // So we add this to public subnets as well if we do not have any private subnets.
if b.Cluster.Spec.Networking.Topology.Nodes == kops.TopologyPublic { if !haveAnyPrivate {
tags[aws.TagNameSubnetInternalELB] = "1" tags[aws.TagNameSubnetInternalELB] = "1"
} }

View File

@ -92,7 +92,7 @@ func (b *AutoscalingGroupModelBuilder) buildInstanceTemplate(c *fi.CloudupModelB
Preemptible: fi.PtrTo(fi.ValueOf(ig.Spec.GCPProvisioningModel) == "SPOT"), Preemptible: fi.PtrTo(fi.ValueOf(ig.Spec.GCPProvisioningModel) == "SPOT"),
GCPProvisioningModel: ig.Spec.GCPProvisioningModel, GCPProvisioningModel: ig.Spec.GCPProvisioningModel,
HasExternalIP: fi.PtrTo(b.Cluster.Spec.Networking.Topology.ControlPlane == kops.TopologyPublic), HasExternalIP: fi.PtrTo(subnet.Type == kops.SubnetTypePublic || subnet.Type == kops.SubnetTypeUtility),
Scopes: []string{ Scopes: []string{
"compute-rw", "compute-rw",

View File

@ -1163,7 +1163,6 @@ resource "aws_subnet" "us-east-1a-utility-complex-example-com" {
"foo/bar" = "fib+baz" "foo/bar" = "fib+baz"
"kubernetes.io/cluster/complex.example.com" = "owned" "kubernetes.io/cluster/complex.example.com" = "owned"
"kubernetes.io/role/elb" = "1" "kubernetes.io/role/elb" = "1"
"kubernetes.io/role/internal-elb" = "1"
} }
vpc_id = aws_vpc.complex-example-com.id vpc_id = aws_vpc.complex-example-com.id
} }
@ -1183,7 +1182,6 @@ resource "aws_subnet" "us-test-1a-complex-example-com" {
"kops.k8s.io/instance-group/nodes" = "true" "kops.k8s.io/instance-group/nodes" = "true"
"kubernetes.io/cluster/complex.example.com" = "owned" "kubernetes.io/cluster/complex.example.com" = "owned"
"kubernetes.io/role/elb" = "1" "kubernetes.io/role/elb" = "1"
"kubernetes.io/role/internal-elb" = "1"
} }
vpc_id = aws_vpc.complex-example-com.id vpc_id = aws_vpc.complex-example-com.id
} }