kubectl apply -f cluster.yaml
When you apply this manifest, a complete Kubernetes workload cluster appears within minutes.
There is no single “cluster-creation controller” or master provisioning engine running behind the scenes. Instead of a central orchestrator executing procedural scripts, independent controllers converge asynchronously through shared Kubernetes API state. Each controller reconciles its own slice of resources in etcd, updates status conditions, and reacts when prerequisite fields populated by neighboring controllers appear.
The Creation Sequence
sequenceDiagram
autonumber
actor Engineer
participant API as Management API
participant CC as Cluster Controller
participant InfraC as InfraCluster Controller
participant KCP as ControlPlane Controller
participant BootC as Bootstrap Controller
participant InfraM as InfraMachine Controller
participant MC as Machine Controller
participant Node as Workload Node
Engineer->>API: kubectl apply -f cluster.yaml
CC->>API: 1. Watches Cluster, adds finalizers
InfraC->>API: 2. Provisions network/LB, sets endpoint
API-->>CC: infrastructureReady = true
KCP->>API: 3. Creates CP Machine & child CRs
BootC->>API: 4. Writes bootstrap Secret
InfraM->>API: 5. Reads Secret, launches VM
Node->>Node: 6. Runs kubeadm init, registers Node
InfraM->>API: Sets InfraMachine.spec.providerID
Node->>API: Reports Node.spec.providerID
MC->>API: 7. Matches providerID, binds nodeRef
API-->>KCP: Initialized = true
API-->>MC: 8. Worker Machines provisioned
MC->>API: 9. Conditions propagate upward
1. Cluster and high-level resources are applied
Applying cluster.yaml creates the declarative blueprint:
Cluster: Root anchor referencing infrastructure and control-plane specs.InfrastructureCluster: Provider networking configuration (e.g.,AWSCluster).KubeadmControlPlane: Control-plane version, replicas, and kubeadm settings.MachineDeployment: Worker pool replicas and machine templates.
The Cluster Controller attaches finalizers to Cluster and sets owner references on InfrastructureCluster. No compute instances can launch yet because shared networking and the control-plane endpoint do not exist.
2. InfrastructureCluster provisions shared infrastructure
The Infrastructure Provider Controller (e.g., CAPA for AWS, CAPD for Docker) reconciles InfrastructureCluster. It provisions shared networking: VPCs, subnets, firewall rules, and the control-plane load balancer.
Once the load balancer is provisioned, the infrastructure controller sets:
status:
ready: true
controlPlaneEndpoint:
host: "api.cluster.example.com"
port: 6443
The Cluster Controller copies controlPlaneEndpoint to Cluster.spec.controlPlaneEndpoint and sets status.infrastructureReady = true. This unblocks control plane creation.
3. KubeadmControlPlane creates a control-plane Machine
With infrastructure ready, the KubeadmControlPlane (KCP) controller:
- Initializes CA Certificates: Stores cluster CAs (
<cluster>-ca,<cluster>-etcd-ca,<cluster>-sa) as Secrets in the management cluster. - Instantiates the Machine: Creates the first control-plane
Machine, labeledcluster.x-k8s.io/control-plane: "". - Clones Child Resources: Creates a concrete
KubeadmConfigand anInfrastructureMachine(e.g.,AWSMachine) from specified templates.
The Machine references these resources via spec.bootstrap.configRef and spec.infrastructureRef.
4. Bootstrap provider generates bootstrap data
The Bootstrap Provider Controller watches KubeadmConfig.
Using CA certificates, the control-plane endpoint, and cluster configuration, it renders a cloud-init or Ignition script with kubeadm init directives and control plane static pod manifests.
It writes this script to a Kubernetes Secret (<machine-name>-bootstrap-data) and sets KubeadmConfig.status.ready = true with status.dataSecretName.
5. Infrastructure provider creates the host
The Infrastructure Provider Controller reconciles the InfrastructureMachine, waiting until spec.bootstrap.dataSecretName appears on the parent Machine.
Once available, the controller:
- Reads the bootstrap script from the management cluster secret.
- Injects it as user-data (e.g., EC2
UserData) via the cloud API. - Launches the compute instance.
Once the instance begins running, the controller marks InfrastructureMachine.status.ready = true.
6. kubeadm starts Kubernetes and kubelet registers a Node
As the host boots:
cloud-initruns, consuming the bootstrap user-data.- It writes certificates to
/etc/kubernetes/pki/and executeskubeadm init. - The container runtime starts static pods for the control plane.
- Once
kube-apiserverresponds,kubeletregisters the host as aNodein the workload cluster.
The node now exists in the workload cluster, but the management cluster has not yet linked it to the Machine CR.
7. providerID links Machine to Node
Machine resources live in the management cluster, while Node resources live in the workload cluster. Because they reside in separate API servers with different names, Cluster API uses providerID as the foreign key to bind them:
- Infrastructure assignment: The infrastructure provider writes the cloud instance ID to
InfrastructureMachine.spec.providerID(e.g.,aws:///us-east-1a/i-0abc12345def). - Machine propagation: The Machine Controller copies this ID to
Machine.spec.providerID. - Node reporting: On the workload host,
kubeletsets the identical ID onNode.spec.providerID. - Binding: The Machine Controller queries the workload API server to match:
Machine.spec.providerID == Node.spec.providerID
When matched, the Machine Controller sets Machine.status.nodeRef to the node name and marks Machine.status.phase = Running. KCP then marks status.initialized = true, unblocking worker joins.
8. MachineDeployment → MachineSet creates worker Machines
With an initialized control plane, worker node provisioning begins:
MachineDeploymentcreates aMachineSetfor desired replicas.MachineSetinstantiates workerMachineobjects, cloningKubeadmConfigandInfrastructureMachinefrom templates.- Bootstrap Controller fetches a join token from the workload cluster and generates a
kubeadm joinbootstrap Secret. - Infrastructure Controller launches worker VMs with the join secret.
- Worker hosts boot, run
kubeadm join, and register as workload nodes. - Machine Controller matches
providerID, binding each workerMachineto itsNode.
9. Status and conditions propagate upward
Cluster API tracks health by bubbling status upward through the hierarchy:
Node / InfrastructureMachine
↓
Machine (phase: Running, nodeRef bound)
↓
KubeadmControlPlane / MachineDeployment
↓
Cluster (infrastructureReady: true, controlPlaneReady: true)
InfrastructureMachinereports VM readiness up toMachine.Machinetransitions toRunningand reports readiness to its parent (KubeadmControlPlaneorMachineSet).MachineSetaggregates worker readiness intoMachineDeployment.status.readyReplicas.KubeadmControlPlaneverifies etcd health and API quorum, markingstatus.ready = true.- Cluster Controller confirms infrastructure and control plane are ready, setting
Cluster.status.phase = ProvisionedandReady = True.
Machine Running != Node Ready
During provisioning, you may observe:
Management Cluster: Machine/md-0-xyz → Phase: Running
Workload Cluster: Node/ip-10-0-2-45 → Status: NotReady (NetworkPluginNotReady)
This is expected behavior:
RunningMachine: Cluster API completed its job. The VM launched, bootstrap scripts ran,kubeletregistered the node, andspec.providerIDboundMachinetoNode.NotReadyNode: Cluster API deliberately does not install a Container Network Interface (CNI) by default. Without a CNI (like Calico or Cilium),kubeletreportsNetworkPluginNotReady(Ready=False).
Once you apply a CNI manifest to the workload cluster, networking initializes and nodes transition to Ready.
Watch it happen
You can observe the controllers converging in real time:
watch -n 2 \
'kubectl get clusters,kubeadmcontrolplanes,machinedeployments,machinesets,machines'
Cluster appears first, followed by KubeadmControlPlane and the first control-plane Machine moving from Pending → Provisioning → Running. Once INITIALIZED: true appears, MachineDeployment and MachineSet launch worker machines.
The Debugging Direction
When creation stalls, debug top-to-bottom following the resource hierarchy:
Cluster
↓
ControlPlane / MachineDeployment
↓
Machine
↓
Bootstrap / Infrastructure
↓
Node
Cluster: IfinfrastructureReadyis false, inspectInfrastructureCluster(e.g.,AWSCluster) for VPC, subnet, or quota failures.ControlPlane/MachineDeployment: Verify desired replicas and control plane endpoint propagation.Machine: Identify which machine is stuck inPendingorProvisioning.Bootstrap/Infrastructure: CheckKubeadmConfigfor secret generation, andInfrastructureMachinefor VM launch errors.Node: IfMachineisRunningbutNodeis absent, check host/var/log/cloud-init-output.log. If present butNotReady, verify CNI installation.