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 2, 2024
1 parent 48eceb9 commit bb65d81
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 @@ -589,9 +589,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 @@ -107,6 +107,19 @@ func getBaseClusterScopeWithLabels() (*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 @@ -742,7 +755,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 bb65d81

Please sign in to comment.