Configure Annotations, Labels, and Taints on Nodes
TOC
Overview
Cluster API (CAPI) can propagate selected Machine metadata to the corresponding Node:
- Labels: via controller manager sync
- Annotations: via controller manager sync
- Taints: via Machine templates (applied during node registration)
This guide shows how to configure each and how to verify they are applied on both Machine and Node resources.
Note: The examples assume your Cluster API controller manager is
capi-controller-managerand that you manageMachineDeploymentandKubeadmControlPlaneobjects for workload and control plane nodes respectively.
Prerequisites
- Permissions to edit the
capi-controller-managerdeployment and cluster API resources - version 4.2.0 or later
1) Sync labels from Machines to Nodes
Step 1: Enable label sync on the controller manager
Add the following argument to the capi-controller-manager container to specify which Machine labels to sync to Nodes:
Replace the comma-separated list with the labels you want to sync.
additional-sync-machine-labels support regex matching.
Step 2: Add labels on Machine templates
-
For workload nodes (
MachineDeployment): set labels on.spec.template.metadata.labels. -
For control plane nodes (
KubeadmControlPlane): set labels on.spec.machineTemplate.metadata.labels.
Verify
2) Sync annotations from Machines to Nodes
Step 1: Enable annotation sync on the controller manager
Add the following argument to the capi-controller-manager container to specify which Machine annotations to sync to Nodes:
additional-sync-machine-annotations support regex matching.
Replace the comma-separated list with the annotations you want to sync.
Step 2: Add annotations on Machine templates
-
For workload nodes (
MachineDeployment): set annotations on.spec.template.metadata.annotations. -
For control plane nodes (
KubeadmControlPlane): set annotations on.spec.machineTemplate.metadata.annotations.
Verify
3) Apply taints from Machines to Nodes
Taints are configured directly on Machine templates so they are applied to the Node during registration.
-
For workload nodes (
MachineDeployment): set taints on.spec.template.taints. -
For control plane nodes (
KubeadmControlPlane): set taints on.spec.machineTemplate.taints.
Verify
Notes
- Ensure field names are spelled correctly:
metadata.labels,metadata.annotations. - Update lists of synced labels/annotations on the controller whenever you add new keys on Machines.
- After changes, allow reconciliation to complete; Node updates may take a short time to appear.