Skip to content

Commit f339899

Browse files
committed
Add support for public-only networking
1 parent 241384f commit f339899

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pkg/cloud/services/elb/loadbalancer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ func (s *Service) getAPIServerLBSpec(elbName string, lbSpec *infrav1.AWSLoadBala
365365
// The load balancer APIs require us to only attach one subnet for each AZ.
366366
subnets := s.scope.Subnets().FilterPrivate().FilterNonCni()
367367

368-
if scheme == infrav1.ELBSchemeInternetFacing {
368+
// public-only setup has no private subnets
369+
if scheme == infrav1.ELBSchemeInternetFacing || len(subnets) == 0 {
369370
subnets = s.scope.Subnets().FilterPublic().FilterNonCni()
370371
}
371372

@@ -1147,7 +1148,8 @@ func (s *Service) getAPIServerClassicELBSpec(elbName string) (*infrav1.LoadBalan
11471148
// The load balancer APIs require us to only attach one subnet for each AZ.
11481149
subnets := s.scope.Subnets().FilterPrivate().FilterNonCni()
11491150

1150-
if scheme == infrav1.ELBSchemeInternetFacing {
1151+
// public-only setup has no private subnets
1152+
if scheme == infrav1.ELBSchemeInternetFacing || len(subnets) == 0 {
11511153
subnets = s.scope.Subnets().FilterPublic().FilterNonCni()
11521154
}
11531155

pkg/cloud/services/network/subnets.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,9 @@ func (s *Service) reconcileSubnets() error {
175175

176176
// When the VPC is managed by CAPA, we need to create the subnets.
177177
if !unmanagedVPC {
178-
// Check that we need at least 1 private and 1 public subnet after we have updated the metadata
178+
// Check that we need at least 1 public subnet after we have updated the metadata
179179
if len(subnets.FilterPrivate()) < 1 {
180-
record.Warnf(s.scope.InfraCluster(), "FailedNoPrivateSubnet", "Expected at least 1 private subnet but got 0")
181-
return errors.New("expected at least 1 private subnet but got 0")
180+
record.Eventf(s.scope.InfraCluster(), "NoPrivateSubnet", "No private subnet found, this is a public-only setup")
182181
}
183182
if len(subnets.FilterPublic()) < 1 {
184183
record.Warnf(s.scope.InfraCluster(), "FailedNoPublicSubnet", "Expected at least 1 public subnet but got 0")

0 commit comments

Comments
 (0)