Provisioning VKS Guest Cluster fails with the following error "Control plane not yet initialized" after reusing a deleted Guest Cluster's name
search cancel

Provisioning VKS Guest Cluster fails with the following error "Control plane not yet initialized" after reusing a deleted Guest Cluster's name

book

Article ID: 435141

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service VMware vSphere ESXi

Issue/Introduction

  • A newly deployed VKS Guest Cluster remains indefinitely stuck in the Provisioning phase when created with the same name as a previously deleted cluster.
  • Describing the cluster reveals the following conditions: 

    kubectl describe cluster <cluster name> -n <namespace name> 

    * ControlPlaneAvailable: Control plane not yet initialized
    * WorkersAvailable:
      * MachineDeployment: 0 available replicas, at least 3 required (spec.strategy.rollout.maxUnavailable is 0, spec.replicas is 3)
        Message:               Addon DNS is not ready: unable to reconcile kubeadm ConfigMap's CoreDNS info: unable to retrieve kubeadm Configmap from the guest cluster: failed to get server groups: Get "https://<Cluster IP>:6443/api?timeout=10s": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
    Addon KubeProxy is not ready: unable to retrieve kube-proxy daemonset from the guest cluster: failed to get server groups: Get "https://<Cluster IP>:6443/api?timeout=10s": context deadline exceeded
    Addon Antrea is not ready:
    Addon Vsphere-Cpi is not ready:
    Addon Vsphere-Pv-Csi is not ready:
    Addon Kapp-Controller is not ready: kapp: Error: Getting app:
      Get "https://<Cluster IP>:6443/api/v1/namespaces/default/configmaps/<guest_cluster_name>-kapp-controller.app.apps.k14s.io": dial tcp <Cluster IP>:6443: i/o timeout

  • The KubeadmControlPlane (KCP) controller logs on the Supervisor cluster reveals an ownerReferences conflict:

    YYYY-MM-DDTHH:MM:SS stderr F       1 controller.go:353] "Reconciler error" err="[failed to patch Secret <namespace_name>/<cluster_name>-kubeconfig: Secret \"<cluster_name>-kubeconfig\" is invalid: metadata.ownerReferences: Invalid value: []v1.OwnerReference{v1.OwnerReference{APIVersion:\"controlplane.cluster.x-k8s.io/v1beta2\", Kind:\"KubeadmControlPlane\", Name:\"<cluster_name>-abc\", UID:\"#####-####-####-######-######\", Controller:(*bool)(0xc066c4f5b1), BlockOwnerDeletion:(*bool)(0xc066c4f5b0)}, v1.OwnerReference{APIVersion:\"controlplane.cluster.x-k8s.io/v1beta2\", Kind:\"KubeadmControlPlane\", Name:\"<cluster_name>-xyz\", UID:\"#####-####-####-######-######\", Controller:(*bool)(0xc066c4f5b3), BlockOwnerDeletion:(*bool)(0xc066c4f5b2)}}: Only one reference can have Controller set to true. Found \"true\" in references for KubeadmControlPlane/<cluster_name>-abc and KubeadmControlPlane/<cluster_name>-xyz, failed to update KubeadmControlPlane status: failed to create remote cluster client: <namespace_name>/<cluster_name>: error getting REST config: connection to the workload cluster is down]" controller="kubeadmcontrolplane" controllerGroup="controlplane.cluster.x-k8s.io" controllerKind="KubeadmControlPlane" KubeadmControlPlane="<namespace_name>/<cluster_name>-xyz" namespace="<namespace_name>" name="<cluster_name>-xyz" reconcileID="#####-####-####-######-######"
    • In this example, <cluster_name>-abc represents the KubeadmControlPlane object from the previously deleted cluster, while <cluster_name>-xyz represents the object for the new cluster."
  • There are secrets for the old cluster still present within the namespace which can be confirmed with the below command: 
    • kubectl get secrets -n <namespace_name> | grep <cluster_name>

      <cluster_name>-pvbackupdriver-secret              kubernetes.io/service-account-token   3      107d
      <cluster_name>-extensions-ca                            kubernetes.io/tls                     3      40h
      <cluster_name>-gateway-api-package                      clusterbootstrap-secret               0      237d
      <cluster_name>-kubeconfig                               cluster.x-k8s.io/secret               1      237d
      <cluster_name>-metrics-server-cert                      kubernetes.io/tls                     3      255d
      <cluster_name>-metrics-server-package                   clusterbootstrap-secret               0      237d
      <cluster_name>-pinniped-package                         clusterbootstrap-secret               1      237d
      <cluster_name>-secretgen-controller-package             clusterbootstrap-secret               1      237d

Environment

vSphere Kubernetes Service

Cause

This issue occurs when a new guest cluster is deployed using the exact same name as a previously deleted cluster in the same vSphere Namespace.

When a cluster is deleted, the core compute objects are removed, but sometimes underlying Kubernetes objects such as kubeconfig secrets, TLS certificates, or CnsNodeVmAttachment objects fail to garbage collect and are left behind. When the new deployment begins, the backend controllers attempt to adopt these stale secrets but are rejected by the Kubernetes API because the secrets are still "owned" by the UUID of the deleted cluster.

Resolution

To resolve this issue, delete the stale Kubernetes objects (such as outdated secrets) from the affected namespace before redeploying the Guest Cluster.

  1. Log in to one of the Control Plane nodes of Supervisor Cluster via SSH. Refer to the following article Troubleshooting vSphere Supervisor Control Plane VMs.
  2. Delete the old secrets present within the namespace for the older cluster: 
    1. kubectl delete secret <cluster_name>-<secret_name> -n <namespace_name>
      NOTE: Be cautious while deleting the secret and only delete the secret for the impacted cluster. 
  3. Delete the cluster stuck in Provisioned state and then apply the YAML again for the cluster: 
    1. kubectl delete cluster <cluster_name> -n <namespace_name>
    2. kubectl apply -f <Guest_Cluster_YAML>.yaml -n <namespace_name> 

The cluster now provisions successfully, and the new nodes deploy as expected.

Additional Information

After deleting and re-creating workload cluster with same name, accessing via "kubectl vsphere login" results in error "You must be logged in to the server" even with correct login