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:

  1. Initializes CA Certificates: Stores cluster CAs (<cluster>-ca, <cluster>-etcd-ca, <cluster>-sa) as Secrets in the management cluster.
  2. Instantiates the Machine: Creates the first control-plane Machine, labeled cluster.x-k8s.io/control-plane: "".
  3. Clones Child Resources: Creates a concrete KubeadmConfig and an InfrastructureMachine (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:

  1. Reads the bootstrap script from the management cluster secret.
  2. Injects it as user-data (e.g., EC2 UserData) via the cloud API.
  3. 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:

  1. cloud-init runs, consuming the bootstrap user-data.
  2. It writes certificates to /etc/kubernetes/pki/ and executes kubeadm init.
  3. The container runtime starts static pods for the control plane.
  4. Once kube-apiserver responds, kubelet registers the host as a Node in the workload cluster.

The node now exists in the workload cluster, but the management cluster has not yet linked it to the Machine CR.


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:

  1. Infrastructure assignment: The infrastructure provider writes the cloud instance ID to InfrastructureMachine.spec.providerID (e.g., aws:///us-east-1a/i-0abc12345def).
  2. Machine propagation: The Machine Controller copies this ID to Machine.spec.providerID.
  3. Node reporting: On the workload host, kubelet sets the identical ID on Node.spec.providerID.
  4. 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:

  1. MachineDeployment creates a MachineSet for desired replicas.
  2. MachineSet instantiates worker Machine objects, cloning KubeadmConfig and InfrastructureMachine from templates.
  3. Bootstrap Controller fetches a join token from the workload cluster and generates a kubeadm join bootstrap Secret.
  4. Infrastructure Controller launches worker VMs with the join secret.
  5. Worker hosts boot, run kubeadm join, and register as workload nodes.
  6. Machine Controller matches providerID, binding each worker Machine to its Node.

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)
  • InfrastructureMachine reports VM readiness up to Machine.
  • Machine transitions to Running and reports readiness to its parent (KubeadmControlPlane or MachineSet).
  • MachineSet aggregates worker readiness into MachineDeployment.status.readyReplicas.
  • KubeadmControlPlane verifies etcd health and API quorum, marking status.ready = true.
  • Cluster Controller confirms infrastructure and control plane are ready, setting Cluster.status.phase = Provisioned and Ready = 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:

  • Running Machine: Cluster API completed its job. The VM launched, bootstrap scripts ran, kubelet registered the node, and spec.providerID bound Machine to Node.
  • NotReady Node: Cluster API deliberately does not install a Container Network Interface (CNI) by default. Without a CNI (like Calico or Cilium), kubelet reports NetworkPluginNotReady (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: If infrastructureReady is false, inspect InfrastructureCluster (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 in Pending or Provisioning.
  • Bootstrap / Infrastructure: Check KubeadmConfig for secret generation, and InfrastructureMachine for VM launch errors.
  • Node: If Machine is Running but Node is absent, check host /var/log/cloud-init-output.log. If present but NotReady, verify CNI installation.