Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For internal Load Balancer use the same API port as external LB #1282

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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