diff --git a/api/v1alpha1/conditions_consts.go b/api/v1alpha1/conditions_consts.go index 382b6f92..9657a065 100644 --- a/api/v1alpha1/conditions_consts.go +++ b/api/v1alpha1/conditions_consts.go @@ -78,6 +78,9 @@ const ( // UnknownReason (Severity=Warning) documents the ProxmoxVM Unknown. UnknownReason = "Unknown" + + // MissingControlPlaneEndpointReason (Severity=Warning) documents the missing Control Plane endpoint. + MissingControlPlaneEndpointReason = "MissingControlPlaneEndpoint" ) const ( diff --git a/internal/controller/proxmoxcluster_controller.go b/internal/controller/proxmoxcluster_controller.go index 5cedab9b..27e05471 100644 --- a/internal/controller/proxmoxcluster_controller.go +++ b/internal/controller/proxmoxcluster_controller.go @@ -168,6 +168,14 @@ func (r *ProxmoxClusterReconciler) reconcileNormal(ctx context.Context, clusterS // If the ProxmoxCluster doesn't have our finalizer, add it. ctrlutil.AddFinalizer(clusterScope.ProxmoxCluster, infrav1alpha1.ClusterFinalizer) + cpe := clusterScope.ControlPlaneEndpoint() + switch { + case cpe.Host == "": + conditions.MarkFalse(clusterScope.ProxmoxCluster, infrav1alpha1.ProxmoxClusterReady, infrav1alpha1.MissingControlPlaneEndpointReason, clusterv1.ConditionSeverityWarning, "The ProxmoxCluster is missing or waiting for a ControlPlaneEndpoint host") + case cpe.Port == 0: + conditions.MarkFalse(clusterScope.ProxmoxCluster, infrav1alpha1.ProxmoxClusterReady, infrav1alpha1.MissingControlPlaneEndpointReason, clusterv1.ConditionSeverityWarning, "The ProxmoxCluster is missing or waiting for a ControlPlaneEndpoint port") + } + res, err := r.reconcileIPAM(ctx, clusterScope) if err != nil { return ctrl.Result{}, err diff --git a/internal/webhook/proxmoxcluster_webhook.go b/internal/webhook/proxmoxcluster_webhook.go index 2e38cc17..0b516c5f 100644 --- a/internal/webhook/proxmoxcluster_webhook.go +++ b/internal/webhook/proxmoxcluster_webhook.go @@ -24,7 +24,6 @@ import ( "regexp" "strings" - infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha1" "github.com/pkg/errors" "go4.org/netipx" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -32,6 +31,8 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha1" ) var _ admission.CustomValidator = &ProxmoxCluster{} @@ -94,6 +95,11 @@ func (*ProxmoxCluster) ValidateUpdate(_ context.Context, _ runtime.Object, newOb func validateControlPlaneEndpoint(cluster *infrav1.ProxmoxCluster) error { ep := cluster.Spec.ControlPlaneEndpoint + // Skipping the validation of the Control Plane endpoint in case of an empty value: + // this is the case of externally managed Control Plane which eventually provides the LB. + if ep.Host == "" && ep.Port == 0 { + return nil + } gk, name := cluster.GroupVersionKind().GroupKind(), cluster.GetName()