Add AKS-owned labels to Flex Nodes - #275
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates FlexNode kubelet label handling to ensure required AKS-managed labels are always applied at kubelet registration time, while preventing those AKS-owned keys from being specified as user/custom node.labels (so ARM Machine “custom labels” remain purely user-defined).
Changes:
- Add a dedicated label builder (
kubeletNodeLabels) that merges custom labels with required AKS-owned labels for kubelet configuration. - Remove the default injection of
kubernetes.azure.com/managed=falseintonode.labelsand instead apply it (and other AKS-owned labels) only when building kubelet labels. - Add validation + tests to reject configs that attempt to set AKS-owned labels via
node.labels.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/config/kubelet_config_test.go | Adds coverage for rejecting AKS-owned labels in node.labels. |
| pkg/config/config.go | Removes default managed label from node.labels and adds validation blocking AKS-owned labels. |
| pkg/config/adapter.go | Introduces AKS-owned label constants and builds kubelet labels via kubeletNodeLabels. |
| pkg/config/adapter_test.go | Adds/updates tests to assert kubelet labels include AKS-owned labels without mutating custom labels. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| // Keep AKS-owned labels out of the custom labels sent in the Machine goal. | ||
| labels[managedNodeLabel] = "false" | ||
| labels[agentPoolNodeLabel] = cfg.Azure.TargetAgentPoolName |
There was a problem hiding this comment.
does AKS RP side process nodes with this agent pool label? Because this could be overrode by user
There was a problem hiding this comment.
Synced offline, this label is immutable after node creation.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pkg/config/adapter.go:181
- The comment above the AKS-owned label additions is misleading: this function returns a label map that includes AKS-owned labels, so they are not being kept "out" of the returned labels. The real behavior is that cfg.Node.Labels (Machine custom labels) is not mutated; AKS-owned labels are added only for kubelet registration.
// Keep AKS-owned labels out of the custom labels sent in the Machine goal.
Summary
node.labelsso Machine goals contain only custom labels.Validation
make checkContext
This is the first independent replacement for draft PR #256.