Skip to content
Open
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
20 changes: 20 additions & 0 deletions pkg/asset/agent/manifests/agentclusterinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ func (a *AgentClusterInstall) Generate(_ context.Context, dependencies asset.Par
agentClusterInstall.Spec.IngressVIPs = installConfig.Config.Platform.BareMetal.IngressVIPs
agentClusterInstall.Spec.APIVIP = installConfig.Config.Platform.BareMetal.APIVIPs[0]
agentClusterInstall.Spec.IngressVIP = installConfig.Config.Platform.BareMetal.IngressVIPs[0]

// Copy LoadBalancer configuration to allow UserManaged load balancer with same API/Ingress VIPs
if installConfig.Config.Platform.BareMetal.LoadBalancer != nil {
agentClusterInstall.Spec.LoadBalancer = &hiveext.LoadBalancer{
Type: convertLoadBalancerType(installConfig.Config.Platform.BareMetal.LoadBalancer.Type),
}
}
} else if installConfig.Config.Platform.VSphere != nil {
vspherePlatform := vsphere.Platform{}
if len(installConfig.Config.Platform.VSphere.APIVIPs) > 1 {
Expand Down Expand Up @@ -654,3 +661,16 @@ func (a *AgentClusterInstall) validateDiskEncryption() field.ErrorList {
}
return allErrs
}

// convertLoadBalancerType converts the configv1 PlatformLoadBalancerType to hiveext LoadBalancerType.
func convertLoadBalancerType(lbType configv1.PlatformLoadBalancerType) hiveext.LoadBalancerType {
switch lbType {
case configv1.LoadBalancerTypeUserManaged:
return hiveext.LoadBalancerTypeUserManaged
case configv1.LoadBalancerTypeOpenShiftManagedDefault:
return hiveext.LoadBalancerTypeClusterManaged
default:
// Default to ClusterManaged if type is empty or unknown
return hiveext.LoadBalancerTypeClusterManaged
}
}
16 changes: 16 additions & 0 deletions pkg/asset/agent/manifests/agentclusterinstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func TestAgentClusterInstall_Generate(t *testing.T) {
goodArbiterACI.Spec.ProvisionRequirements.ArbiterAgents = 1
goodArbiterACI.Spec.ProvisionRequirements.WorkerAgents = 0

installConfigWithUserManagedLB := getValidOptionalInstallConfigWithUserManagedLB()
goodUserManagedLBACI := getGoodACI()
goodUserManagedLBACI.Spec.LoadBalancer = &hiveext.LoadBalancer{
Type: hiveext.LoadBalancerTypeUserManaged,
}

cases := []struct {
name string
dependencies []asset.Asset
Expand Down Expand Up @@ -322,6 +328,16 @@ func TestAgentClusterInstall_Generate(t *testing.T) {
},
expectedConfig: goodArbiterACI,
},
{
name: "valid configuration with UserManaged LoadBalancer",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
installConfigWithUserManagedLB,
&agentconfig.AgentHosts{},
&agentconfig.AgentConfig{},
},
expectedConfig: goodUserManagedLBACI,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
10 changes: 10 additions & 0 deletions pkg/asset/agent/manifests/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"k8s.io/utils/ptr"
"sigs.k8s.io/yaml"

configv1 "github.com/openshift/api/config/v1"
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
"github.com/openshift/assisted-service/api/v1beta1"
hivev1 "github.com/openshift/hive/apis/hive/v1"
Expand Down Expand Up @@ -603,6 +604,15 @@ func getInValidAgentHostsConfig() *agentconfig.AgentHosts {
}
}

// getValidOptionalInstallConfigWithUserManagedLB returns a valid optional install config with UserManaged load balancer.
func getValidOptionalInstallConfigWithUserManagedLB() *agent.OptionalInstallConfig {
installConfig := getValidOptionalInstallConfig()
installConfig.Config.Platform.BareMetal.LoadBalancer = &configv1.BareMetalPlatformLoadBalancer{
Type: configv1.LoadBalancerTypeUserManaged,
}
return installConfig
}

func getGoodACIDualStack() *hiveext.AgentClusterInstall {
goodACI := getGoodACI()
goodACI.Spec.Networking.MachineNetwork = append(goodACI.Spec.Networking.MachineNetwork, hiveext.MachineNetworkEntry{
Expand Down