Skip to content

fix(syncer): apply the node selector to pods that set nodeName - #4273

Open
blacksoxx wants to merge 1 commit into
loft-sh:mainfrom
blacksoxx:nodename-respects-node-selector
Open

blacksoxx wants to merge 1 commit into
loft-sh:mainfrom
blacksoxx:nodename-respects-node-selector

Conversation

@blacksoxx

@blacksoxx blacksoxx commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What issue type does this pull request address?
/kind bugfix

What does this pull request do? Which issues does it resolve?
resolves #4272

With a node selector configured, pods that set spec.nodeName skipped the selector entirely; only the existence of a virtual Node with that name was checked, and a tenant can create such a Node. The selector is now merged into the pod's nodeSelector in both cases, so a pod pinned to a node outside the selector is rejected by that node's kubelet at admission instead of running there. The existence check stays.

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where a pod with spec.nodeName set could run on host nodes outside sync.fromHost.nodes.selector.

What else do we need to know?
Unit test added for both the pinned and the unpinned case.


Note

Medium Risk
Changes pod-to-host sync behavior for pinned pods and affects scheduling enforcement at kubelet admission; scope is limited to the pod syncer with new unit coverage.

Overview
Fixes a bypass where pods with spec.nodeName set could sync to the host without sync.fromHost.nodes.selector labels on the physical pod.

SyncToHost now always merges the configured selector into the physical pod’s nodeSelector (pinned or not), so the kubelet rejects pods bound to nodes outside the selector. The existing virtual Node existence check when nodeName is set is unchanged.

Adds TestSyncToHostNodeSelectorWithNodeName covering pinned and unpinned pods.

Reviewed by Cursor Bugbot for commit 35dd2bf. Bugbot is set up for automated code reviews on this repo. Configure here.

With sync.fromHost.nodes.selector configured, a pod that set spec.nodeName skipped the selector; only the existence of a virtual Node with that name was checked, and a tenant can create such a Node. The selector is now merged into the host pod's nodeSelector in both cases, so a pod pinned to a node outside the selector is rejected by that node's kubelet at admission instead of running there.

Signed-off-by: Youssef Omar Bouden <youssef.bouden2002@gmail.com>

This branch has not been deployed

No deployments
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.

Pods that set spec.nodeName bypass sync.fromHost.nodes.selector

1 participant