From 92744524eeb106d1d14d10262056e1e892f440a0 Mon Sep 17 00:00:00 2001 From: Alan Amoyel Date: Tue, 25 Apr 2023 19:24:39 +0200 Subject: [PATCH] condition to use controlPlaneEndpoint values --- controllers/kubevirtcluster_controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/controllers/kubevirtcluster_controller.go b/controllers/kubevirtcluster_controller.go index 632f1212..8158e156 100644 --- a/controllers/kubevirtcluster_controller.go +++ b/controllers/kubevirtcluster_controller.go @@ -154,8 +154,14 @@ func (r *KubevirtClusterReconciler) reconcileNormal(ctx *context.ClusterContext, } } - // Get LoadBalancer ExternalIP if cluster Service Type is LoadBalancer - if ctx.KubevirtCluster.Spec.ControlPlaneServiceTemplate.Spec.Type == "LoadBalancer" { + // Get the ControlPlane Host and Port manually set by the user if existing + if ctx.KubevirtCluster.Spec.ControlPlaneEndpoint.Host != "" { + ctx.KubevirtCluster.Spec.ControlPlaneEndpoint = infrav1.APIEndpoint{ + Host: ctx.KubevirtCluster.Spec.ControlPlaneEndpoint.Host, + Port: ctx.KubevirtCluster.Spec.ControlPlaneEndpoint.Port, + } + // Get LoadBalancer ExternalIP if cluster Service Type is LoadBalancer + } else if ctx.KubevirtCluster.Spec.ControlPlaneServiceTemplate.Spec.Type == "LoadBalancer" { lbip4, err := externalLoadBalancer.ExternalIP(ctx) if err != nil { conditions.MarkFalse(ctx.KubevirtCluster, infrav1.LoadBalancerAvailableCondition, infrav1.LoadBalancerProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())