When deploying a Kubernetes cluster with the DKP vSphere provider, it's possible to get into a situation where the first machine object is shown as Ready but the corresponding VM is not being created.
For example, when describing the cluster, we can see that the Machine/dkp240-rhel84-vsphere-control-plallprt is in Ready status, but the corresponding VM is not being created:
./dkp describe cluster -c dkp240-rhel84-vsphere
NAME READY SEVERITY REASON SINCE MESSAGE
Cluster/dkp240-rhel84-vsphere-airgap False Warning ScalingUp 6m4s Scaling up control plane to 3 replicas (actual 1)
├─ClusterInfrastructure - VSphereCluster/dkp240-rhel84-vsphere True 6m11s
├─ControlPlane - KubeadmControlPlane/dkp240-rhel84-vsphere-control-plane False Warning ScalingUp 6m4s Scaling up control plane to 3 replicas (actual 1)
│ └─Machine/dkp240-rhel84-vsphere-control-plallprt True 6m7s
└─Workers
└─MachineDeployment/dkp240-rhel84-vsphere-md-0 False Warning WaitingForAvailableMachines 6m13s Minimum availability requires 4 replicas, current 0 available
├─Machine/dkp240-rhel84-vsphere-md-0-5dc458b54zw False Info WaitingForControlPlaneAvailable 6m10s 0 of 2 completed
├─Machine/dkp240-rhel84-vsphere-md-0-5dc458bdlfg False Info WaitingForControlPlaneAvailable 6m10s 0 of 2 completed
├─Machine/dkp240-rhel84-vsphere-md-0-5dc458lq4tv False Info WaitingForControlPlaneAvailable 6m10s 0 of 2 completed
└─Machine/dkp240-rhel84-vsphere-md-0-5dc458rrqp8 False Info WaitingForControlPlaneAvailable 6m10s 0 of 2 completed
Inspecting the cluster-api vsphere controller logs shows that the VM folder cannot be found on the vsphere server:
kubectl -n capv-system -l=cluster.x-k8s.io/provider=infrastructure-vsphere logs
E0510 15:23:04.035265 1 controller.go:317] controller/vspherevm "msg"="Reconciler error"
"error"="failed to reconcile VM: folder 'sortega/dkp240' not found" "name"="dkp240-rhel84-vsphere-control-plallprt" "namespace"="default" "reconciler group"="infrastructure.cluster.x-k8s.io" "reconciler kind"="VSphereVM"
Solution
The folder is specified in the vspheremachinetemplate objects and 2 of these objects exists on each cluster:
kubectl get vspheremachinetemplate NAME AGE
dkp240-rhel84-vsphere-control-plane 10m
dkp240-rhel84-vsphere-md-0 10m
As the vspheremachinetemplate is immutable, it cannot be edited:
kubectl edit vspheremachinetemplate dkp240-rhel84-vsphere-control-plane
error: vspheremachinetemplates.infrastructure.cluster.x-k8s.io
"dkp240-rhel84-vsphere-control-plane" could not be patched: admission webhook
"validation.vspheremachinetemplate.infrastructure.x-k8s.io" denied the request:
spec: Forbidden: VSphereMachineTemplateSpec is immutable
To correct this issue, you should delete the cluster (dkp delete cluster -c ... --delete-kubernetes-resources=false), fix the folder issue, and then recreate the cluster.