Skip to content

Commit

Permalink
For internal Load Balancer use the same API port as external LB
Browse files Browse the repository at this point in the history
  • Loading branch information
bfournie committed Jul 29, 2024
1 parent 890c3cb commit 5d4d048
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cloud/services/compute/loadbalancers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,14 @@ func (s *Service) createOrGetRegionalForwardingRule(ctx context.Context, lbname
spec.LoadBalancingScheme = string(loadBalanceTrafficInternal)
spec.Region = s.scope.Region()
spec.BackendService = backendSvc.SelfLink
// Ports are used instead or PortRange for passthrough Load Balancer
// Configure ports for k8s API and ignition
spec.Ports = []string{"6443", "22623"}
// Ports is used instead or PortRange for passthrough Load Balancer
// Configure ports for k8s API to match the external API which is the first port of range
var ports []string
portList := strings.Split(spec.PortRange, "-")
ports = append(ports, portList[0])
// Also configure ignition port
ports = append(ports, "22623")
spec.Ports = ports
spec.PortRange = ""
subnet, err := s.getSubnet(ctx)
if err != nil {
Expand Down
15 changes: 14 additions & 1 deletion cloud/services/compute/loadbalancers/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ func getBaseClusterScopeWithSharedVPC() (*scope.ClusterScope, error) {
return clusterScope, nil
}

func getBaseClusterScopeWithPortSet() (*scope.ClusterScope, error) {
clusterScope, err := getBaseClusterScope()
if err != nil {
return nil, err
}

port := int32(6443)
clusterScope.Cluster.Spec.ClusterNetwork = &clusterv1.ClusterNetwork{
APIServerPort: &port,
}
return clusterScope, nil
}

func TestService_createOrGetInstanceGroup(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -811,7 +824,7 @@ func TestService_createOrGetRegionalForwardingRule(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := context.TODO()
clusterScope, err := getBaseClusterScope()
clusterScope, err := getBaseClusterScopeWithPortSet()
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 5d4d048

Please sign in to comment.