Skip to content

Commit 2ee5e91

Browse files
committed
docs: document ClusterClass rotation behavior for MachinePool objects
Signed-off-by: Bharath Nallapeta <nr.bharath97@gmail.com>
1 parent 99872f1 commit 2ee5e91

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

docs/book/src/developer/providers/contracts/bootstrap-config.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ repo or add an item to the agenda in the [Cluster API community meeting](https:/
5555
| [BootstrapConfig: terminal failures] | No | |
5656
| [BootstrapConfigTemplate, BootstrapConfigTemplateList resource definition] | Yes | |
5757
| [BootstrapConfigTemplate: support for SSA dry run] | No | Mandatory for ClusterClasses support |
58+
| [ClusterClass topology controller behavior for MachinePools] | No | Mandatory for ClusterClasses support |
5859
| [Sentinel file] | No | |
5960
| [Taint Nodes at creation] | No | |
61+
| [Infrastructure provider watching for bootstrap changes] | No | |
6062
| [Support for running multiple instances] | No | Mandatory for clusterctl CLI support |
6163
| [Clusterctl support] | No | Mandatory for clusterctl CLI support |
6264
| [BootstrapConfig: pausing] | No | |
@@ -420,6 +422,33 @@ validation behavior for all other cases.
420422

421423
See [the DockerMachineTemplate webhook] as a reference for a compatible implementation.
422424

425+
### ClusterClass topology controller behavior for MachinePools
426+
427+
When using ClusterClass and managed topologies with MachinePools, the topology controller creates BootstrapConfig objects
428+
from BootstrapConfigTemplates. Unlike templates (which are immutable), these BootstrapConfig objects have mutable specs,
429+
but the topology controller handles spec changes through a **rotation strategy** rather than in-place updates.
430+
431+
When the topology controller detects that the BootstrapConfigTemplate has changed (e.g., from template updates
432+
in ClusterClass), it performs a **rotation**:
433+
434+
1. Creates a new BootstrapConfig object with a new name
435+
2. Updates the MachinePool's `spec.template.spec.bootstrap.configRef` to reference the new object
436+
3. The old BootstrapConfig is garbage collected when no longer referenced
437+
438+
<aside class="note">
439+
440+
<h1>Provider expectations for rotation</h1>
441+
442+
Bootstrap providers SHOULD be aware that when used with MachinePools, the BootstrapConfig object may be rotated
443+
(replaced with a new object) rather than updated in-place when spec changes occur.
444+
445+
</aside>
446+
447+
Metadata-only changes (labels, annotations) MUST NOT trigger rotation; they are patched in-place on the existing object.
448+
449+
Note: This rotation behavior is specific to MachinePools. For individual Machines (e.g., in MachineDeployments), BootstrapConfig
450+
objects are created per-Machine and follow the standard Machine lifecycle.
451+
423452
### Sentinel file
424453

425454
A bootstrap provider's bootstrap data must create `/run/cluster-api/bootstrap-success.complete`
@@ -433,6 +462,13 @@ This taint is used to prevent workloads to be scheduled on Nodes before the node
433462
As of today the Node initialization consists of syncing labels from Machines to Nodes. Once the labels have been
434463
initially synced the taint is removed from the Node.
435464

465+
### Infrastructure provider watching for bootstrap changes
466+
467+
Infrastructure providers watching for bootstrap changes SHOULD monitor the MachinePool's `spec.template.spec.bootstrap.configRef.name`
468+
field. When the reference name changes, this indicates a rotation has occurred and may require triggering a node rollout.
469+
470+
This pattern is consistent with how MachineDeployments handle BootstrapTemplate rotations.
471+
436472
### Support for running multiple instances
437473

438474
Cluster API does not support running multiples instances of the same provider, which someone can
@@ -502,8 +538,10 @@ The following diagram shows the typical logic for a bootstrap provider:
502538
[BootstrapConfig: terminal failures]: #bootstrapconfig-terminal-failures
503539
[BootstrapConfigTemplate, BootstrapConfigTemplateList resource definition]: #bootstrapconfigtemplate-bootstrapconfigtemplatelist-resource-definition
504540
[BootstrapConfigTemplate: support for SSA dry run]: #bootstrapconfigtemplate-support-for-ssa-dry-run
541+
[ClusterClass topology controller behavior for MachinePools]: #clusterclass-topology-controller-behavior-for-machinepools
505542
[Sentinel file]: #sentinel-file
506543
[Taint Nodes at creation]: #taint-nodes-at-creation
544+
[Infrastructure provider watching for bootstrap changes]: #infrastructure-provider-watching-for-bootstrap-changes
507545
[Support for running multiple instances]: #support-for-running-multiple-instances
508546
[Support running multiple instances of the same provider]: ../../core/support-multiple-instances.md
509547
[Clusterctl support]: #clusterctl-support

docs/book/src/developer/providers/contracts/infra-machinepool.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ To provide feedback or open a discussion about the provider contract please [ope
5555
| [InfraMachinePool: terminal failures] | No | |
5656
| [InfraMachinePoolTemplate, InfraMachineTemplatePoolList resource definition] | No | Mandatory for ClusterClasses support |
5757
| [InfraMachinePoolTemplate: support for SSA dry run] | No | Mandatory for ClusterClasses support |
58+
| [ClusterClass topology controller behavior] | No | Mandatory for ClusterClasses support |
5859
| [Multi tenancy] | No | Mandatory for clusterctl CLI support |
5960
| [Clusterctl support] | No | Mandatory for clusterctl CLI support |
6061

@@ -495,6 +496,36 @@ The implementation requires to use controller runtime's `CustomValidator`, avail
495496
This will allow to skip the immutability check only when the topology controller is dry running while preserving the
496497
validation behavior for all other cases.
497498

499+
### ClusterClass topology controller behavior
500+
501+
When using ClusterClass and managed topologies, the topology controller creates InfraMachinePool objects from InfraMachinePoolTemplates.
502+
Unlike templates (which are immutable), these InfraMachinePool objects have mutable specs, but the topology controller
503+
handles spec changes through a **rotation strategy** rather than in-place updates.
504+
505+
When the topology controller detects that the InfraMachinePoolTemplate has changed (e.g., from template updates in ClusterClass), it performs
506+
a **rotation**:
507+
508+
1. Creates a new InfraMachinePool object with a new name
509+
2. Copies `spec.providerIDList` from the old InfraMachinePool to the new one (to preserve instance tracking)
510+
3. Updates the MachinePool's `spec.template.spec.infrastructureRef` to reference the new object
511+
4. The old InfraMachinePool is garbage collected when no longer referenced
512+
513+
<aside class="note">
514+
515+
<h1>Provider expectations for rotation</h1>
516+
517+
Providers SHOULD watch for changes to the MachinePool's `spec.template.spec.infrastructureRef.name` field.
518+
When the reference name changes, this indicates a rotation has occurred and the provider SHOULD:
519+
520+
- Use the `spec.providerIDList` from the new InfraMachinePool to identify existing instances
521+
- Trigger any necessary rollout or reconciliation based on the spec changes
522+
523+
This pattern is consistent with how MachineDeployments handle InfrastructureMachineTemplate rotations.
524+
525+
</aside>
526+
527+
Metadata-only changes (labels, annotations) MUST NOT trigger rotation; they are patched in-place on the existing object.
528+
498529
### Multi tenancy
499530

500531
Multi tenancy in Cluster API defines the capability of an infrastructure provider to manage different credentials,
@@ -532,6 +563,7 @@ The clusterctl command is designed to work with all the providers compliant with
532563
[InfraMachinePool: terminal failures]: #inframachinepool-terminal-failures
533564
[InfraMachinePoolTemplate, InfraMachineTemplatePoolList resource definition]: #inframachinepooltemplate-inframachinetemplatepoollist-resource-definition
534565
[InfraMachinePoolTemplate: support for SSA dry run]: #inframachinepooltemplate-support-for-ssa-dry-run
566+
[ClusterClass topology controller behavior]: #clusterclass-topology-controller-behavior
535567
[MachinePoolMachines support]: #machinepoolmachines-support
536568
[Multi tenancy]: #multi-tenancy
537569
[Clusterctl support]: #clusterctl-support

0 commit comments

Comments
 (0)