When managing worker nodes in Cluster API (CAPI), you do not interact with virtual machines directly. Cluster API organizes worker infrastructure into a declarative three-tier hierarchy mirroring standard Kubernetes workload controllers:

Deployment        → MachineDeployment
ReplicaSet        → MachineSet
Pod               → Machine

Anchor on this central mental model:

MachineDeployment = rollout and revision
MachineSet        = replica count
Machine           = one host lifecycle

While this structural symmetry provides an immediate mental anchor, there is a fundamental difference in operational weight:

Machines are more expensive and stateful to replace than Pods, so rollout operations include infrastructure provisioning and Node drain behavior.

A Pod starts in seconds inside shared kernel namespaces. A Machine provisions a cloud VM or bare-metal host, attaches storage, runs cloud-init, and registers a Node. Replacing Machines therefore requires asynchronous cloud provisioning on scale-up and coordinated Node draining (cordoning, evicting pods respecting PodDisruptionBudgets, and detaching volumes) on scale-down.


Machine

The Machine resource represents one host lifecycle—the declarative infrastructure counterpart to a Pod.

A Machine coordinates host lifecycle by referencing two provider resources:

  • bootstrap.configRef: Points to a bootstrap resource (e.g., KubeadmConfig) generating cloud-init scripts, certificates, and join tokens.
  • infrastructureRef: Points to an infrastructure resource (e.g., AWSMachine or AzureMachine) requesting the physical host or VM.
flowchart LR
    M["Machine (Host Lifecycle)"] --> BC["bootstrapRef (KubeadmConfig)"]
    M --> IM["infrastructureRef (AWSMachine)"]
    IM --> VM["Cloud VM / Host"]
    VM --> NODE["Workload Node"]
    M -.->|"spec.providerID == Node.spec.providerID"| NODE

Mapping eventually to one Node

A Machine exists in the management cluster and maps eventually to one Node in the workload cluster. The Machine controller bridges these separate clusters using spec.providerID:

  1. The cloud assigns a unique instance ID (e.g., aws:///us-east-1a/i-0123456789abcdef0).
  2. The infrastructure controller sets InfrastructureMachine.spec.providerID, which CAPI copies to Machine.spec.providerID.
  3. When kubelet joins the workload cluster, it reports that same providerID on its Node.
  4. The Machine controller matches the IDs and populates Machine.status.nodeRef.

Machine deletion

Machine deletion may include Node drain, volume detach and infrastructure cleanup.

Because a Machine represents a live host, CAPI cordons the workload Node, evicts pods respecting PodDisruptionBudgets, detaches storage volumes, and terminates the underlying host.


MachineSet

The MachineSet resource maintains N Machines—the infrastructure counterpart to a ReplicaSet.

Its sole responsibility is replica count convergence. Given a target replica count and a machine template, the MachineSet controller continuously compares desired replicas against observed Machine objects:

  • Scaling up (3 → 5): Scaling 3 → 5 means create two Machines. The controller creates two Machine objects, cloning the referenced templates into per-machine resources.
  • Scaling down (5 → 3): The controller selects two Machine objects for deletion, triggering their node drain and cleanup.

Operators rarely manage MachineSet resources directly; they are stamped out, scaled, and managed automatically by a parent MachineDeployment.


MachineDeployment

The MachineDeployment resource manages MachineSet revisions and worker rollouts—the infrastructure counterpart to a Kubernetes Deployment.

The MachineDeployment provides fleet-wide desired state:

  • Worker replica count.
  • The blueprint template for workers (Kubernetes version, instance types, OS images, labels).
  • Rollout strategy (RollingUpdate or OnDelete).

When you scale capacity or update worker configuration, you edit the MachineDeployment. The controller handles revision tracking: it hashes the machine template, creates a new MachineSet when the template changes, and shifts replicas between the old and new MachineSets.

(Note: While RollingUpdate is standard, MachineDeployment also supports OnDelete, where replacements are provisioned only when older machines are manually deleted.)


Scale vs rollout

The difference between scaling and rolling out updates comes down to whether the template changes:

  • Scaling: Same template, replica count changes. MachineDeployment updates replicas on the existing MachineSet.
  • Rollout: Desired Machine template changes, so a new MachineSet and replacement Machines may be required.

RollingUpdate in action

During a rollout, MachineDeployment avoids downtime by using a RollingUpdate strategy governed by two parameters:

  • maxSurge: How many additional Machines can be created above the desired replica count (default: 1).
  • maxUnavailable: How many Machines can be unavailable relative to the desired replica count during the rollout (default: 0).

Consider a MachineDeployment with replicas: 3, maxSurge: 1, and maxUnavailable: 0:

Step 0: Steady State (v1)
  MS-v1 (old): replicas=3, available=3
  MS-v2 (new): replicas=0, available=0
  Total: 3 machines (Desired: 3)

Step 1: Surge New Capacity
  MS-v1 (old): replicas=3, available=3
  MS-v2 (new): replicas=1, available=0 (Provisioning VM...)
  Total: 4 machines (3 desired + 1 maxSurge)

Step 2: New Machine Becomes Available
  MS-v1 (old): replicas=3, available=3
  MS-v2 (new): replicas=1, available=1 (Node ready)
  Available: 4 (>= 3 desired - 0 maxUnavailable)

Step 3: Drain & Scale Down Old MachineSet
  MS-v1 (old): replicas=2, available=2 (Old host drained & deleted)
  MS-v2 (new): replicas=1, available=1
  Total: 3 machines, Available: 3

[Process repeats until MS-v1 reaches 0 and MS-v2 reaches 3]

Because maxUnavailable: 0, the old node is not drained or terminated until the new node has booted, joined the cluster, and reported ready.

Infrastructure-template immutability

In Cluster API, infrastructure and bootstrap templates are immutable:

Do not mutate an infrastructure template in place. Create a new template and point the MachineDeployment at it.

If you edit an existing AWSMachineTemplate in place, controllers do not detect a template hash change, existing machines will not update, and reconciliations produce inconsistent configurations.

The practical rule is always:

  1. Create a new template resource (e.g., prod-worker-amt-v2 with updated instance type or AMI).
  2. Point MachineDeployment.spec.template.spec.infrastructureRef.name at prod-worker-amt-v2.
  3. MachineDeployment detects the change, derives a new hash, and initiates rolling replacement.

Practical lab: Inspecting hierarchy and scaling

Observe the worker hierarchy and controller convergence using kubectl on your management cluster:

1. View the complete hierarchy

kubectl get machinedeployments,machinesets,machines

The output displays the tree: MachineDeployment owns the MachineSet (reflected in the name and template hash), and MachineSet owns the individual Machine objects.

2. Scale the MachineDeployment

kubectl scale machinedeployment <name> --replicas=2

3. Watch convergence in real time

watch -n 2 \
  'kubectl get machinedeployments,machinesets,machines'

During scale-down, MachineDeployment decrements replicas on the MachineSet. The MachineSet selects a Machine to delete, which cordons and drains the workload node before the VM terminates.


Summary

To navigate Cluster API worker management with confidence, remember the core division of responsibilities:

MachineDeployment = rollout
MachineSet        = replicas
Machine           = host lifecycle

By separating rollouts from replica counting and host lifecycle mechanics, Cluster API brings the safety and predictability of Kubernetes workload controllers to infrastructure hosts.


Next in the series

Now that we understand how MachineDeployment, MachineSet, and Machine controllers interact, explore Part 8: Scaling Kubernetes Clusters with Cluster API to see how manual scale operations and automated autoscaling interact with this hierarchy in practice.


References & Further Reading