Skip to content

Commit 5d4d048

Browse files
committed
For internal Load Balancer use the same API port as external LB
1 parent 890c3cb commit 5d4d048

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

cloud/services/compute/loadbalancers/reconcile.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,14 @@ func (s *Service) createOrGetRegionalForwardingRule(ctx context.Context, lbname
601601
spec.LoadBalancingScheme = string(loadBalanceTrafficInternal)
602602
spec.Region = s.scope.Region()
603603
spec.BackendService = backendSvc.SelfLink
604-
// Ports are used instead or PortRange for passthrough Load Balancer
605-
// Configure ports for k8s API and ignition
606-
spec.Ports = []string{"6443", "22623"}
604+
// Ports is used instead or PortRange for passthrough Load Balancer
605+
// Configure ports for k8s API to match the external API which is the first port of range
606+
var ports []string
607+
portList := strings.Split(spec.PortRange, "-")
608+
ports = append(ports, portList[0])
609+
// Also configure ignition port
610+
ports = append(ports, "22623")
611+
spec.Ports = ports
607612
spec.PortRange = ""
608613
subnet, err := s.getSubnet(ctx)
609614
if err != nil {

cloud/services/compute/loadbalancers/reconcile_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ func getBaseClusterScopeWithSharedVPC() (*scope.ClusterScope, error) {
117117
return clusterScope, nil
118118
}
119119

120+
func getBaseClusterScopeWithPortSet() (*scope.ClusterScope, error) {
121+
clusterScope, err := getBaseClusterScope()
122+
if err != nil {
123+
return nil, err
124+
}
125+
126+
port := int32(6443)
127+
clusterScope.Cluster.Spec.ClusterNetwork = &clusterv1.ClusterNetwork{
128+
APIServerPort: &port,
129+
}
130+
return clusterScope, nil
131+
}
132+
120133
func TestService_createOrGetInstanceGroup(t *testing.T) {
121134
tests := []struct {
122135
name string
@@ -811,7 +824,7 @@ func TestService_createOrGetRegionalForwardingRule(t *testing.T) {
811824
for _, tt := range tests {
812825
t.Run(tt.name, func(t *testing.T) {
813826
ctx := context.TODO()
814-
clusterScope, err := getBaseClusterScope()
827+
clusterScope, err := getBaseClusterScopeWithPortSet()
815828
if err != nil {
816829
t.Fatal(err)
817830
}

0 commit comments

Comments
 (0)