Skip to content

Commit

Permalink
Merge pull request #2363 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2339-to-release-0.11

[release-0.11] 🐛 fix: create lbaas in specified subnet
  • Loading branch information
k8s-ci-robot authored Jan 14, 2025
2 parents 524ad95 + 3c06579 commit 584613e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions controllers/openstackcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,15 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
for _, s := range lbSpec.Subnets {
matchFound := false
for _, subnetID := range lbNet.Subnets {
if s.ID != nil && subnetID == *s.ID {
subnet, err := networkingService.GetSubnetByParam(&s)
if s.ID != nil && subnetID == *s.ID && err == nil {
matchFound = true
lbNetStatus.Subnets = append(
lbNetStatus.Subnets, infrav1.Subnet{
ID: *s.ID,
ID: subnet.ID,
Name: subnet.Name,
CIDR: subnet.CIDR,
Tags: subnet.Tags,
})
}
}
Expand All @@ -640,6 +644,8 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
return fmt.Errorf("no subnet match was found in the specified network (specified subnet: %v, available subnets: %v)", s, lbNet.Subnets)
}
}

openStackCluster.Status.APIServerLoadBalancer.LoadBalancerNetwork = lbNetStatus
}
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/cloud/services/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,11 @@ func (s *Service) getOrCreateAPILoadBalancer(openStackCluster *infrav1.OpenStack
if vipNetworkID == "" && vipSubnetID == "" {
// keep the default and create the VIP on the first cluster subnet
vipSubnetID = openStackCluster.Status.Network.Subnets[0].ID
s.scope.Logger().Info("No load balancer network specified, creating load balancer in the default subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
} else {
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
}

s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)

providers, err := s.loadbalancerClient.ListLoadBalancerProviders()
if err != nil {
return nil, err
Expand Down

0 comments on commit 584613e

Please sign in to comment.