Skip to content

Add AKS-owned labels to Flex Nodes - #275

Merged
hbc (bcho) merged 3 commits into
mainfrom
wenx/server-owned-labels
Aug 14, 2026
Merged

Add AKS-owned labels to Flex Nodes#275
hbc (bcho) merged 3 commits into
mainfrom
wenx/server-owned-labels

Conversation

@wenxuan0923

Copy link
Copy Markdown
Collaborator

Summary

  • Add the AKS-managed, agent-pool, mode, and node-pool-type labels when building kubelet configuration.
  • Keep those server-owned labels out of node.labels so Machine goals contain only custom labels.
  • Reject configuration that attempts to set an AKS-owned label.

Validation

  • make check

Context

This is the first independent replacement for draft PR #256.

@wenxuan0923
Wenxuan W (wenxuan0923) marked this pull request as ready for review August 14, 2026 20:54
Copilot AI lite review requested due to automatic review settings August 14, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=false into node.labels and 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.

Comment thread pkg/config/adapter.go
Comment thread pkg/config/adapter.go

// Keep AKS-owned labels out of the custom labels sent in the Machine goal.
labels[managedNodeLabel] = "false"
labels[agentPoolNodeLabel] = cfg.Azure.TargetAgentPoolName

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does AKS RP side process nodes with this agent pool label? Because this could be overrode by user

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline, this label is immutable after node creation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bcho
hbc (bcho) merged commit 981f1cd into main Aug 14, 2026
13 of 14 checks passed
@bcho
hbc (bcho) deleted the wenx/server-owned-labels branch August 14, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants