Node affinity is a Kubernetes scheduling mechanism that allows you to constrain which nodes your Pod is eligible to be scheduled on, based on labels on the node. It provides a more expressive and powerful alternative to the older nodeSelector field. Rules are defined using affinity and anti-affinity specifications within a Pod's configuration, which can be either required during scheduling (requiredDuringSchedulingIgnoredDuringExecution) or treated as a preference (preferredDuringSchedulingIgnoredDuringExecution). This enables fine-grained control over workload placement, crucial for matching Pod requirements to node capabilities like specific hardware (e.g., GPUs, NPUs) or location.
Glossary
Node Affinity

What is Node Affinity?
Node affinity is a core Kubernetes scheduling feature that constrains which nodes a Pod can be placed on, based on labels on the node, allowing rules to be expressed as either hard requirements or soft preferences.
In Edge AI Orchestration, node affinity is essential for pinning latency-sensitive inference workloads to nodes with specific accelerators (like an NPU) or to nodes in a particular geographic zone. You can use nodeSelectorTerms with operators like In, NotIn, Exists, and DoesNotExist to match complex label combinations. For example, you can require a Pod to run on a node labeled with accelerator=npu-v1 and zone=us-west-1a. This ensures AI models execute on optimized hardware, minimizing inference latency and meeting the deterministic performance requirements of edge deployments without relying on cloud connectivity.
Key Features of Node Affinity
Node affinity is a Kubernetes scheduling feature that constrains which nodes a Pod can be placed on, based on labels on the node, allowing rules to be expressed as either hard requirements or soft preferences.
Node Selector (Simplified Affinity)
The simplest form of node affinity is the nodeSelector field, which specifies a set of key-value label pairs a node must have for a Pod to be schedulable. It functions as a hard requirement with simple equality-based matching.
- Example:
nodeSelector: { "disktype": "ssd", "gpu": "nvidia" }ensures the Pod only runs on nodes with both labels. - It is a legacy, less expressive precursor to the full
nodeAffinitysyntax.
RequiredDuringSchedulingIgnoredDuringExecution (Hard Affinity)
This rule type defines mandatory constraints that must be met for a Pod to be scheduled onto a node. If no node satisfies the rule, the Pod remains unscheduled (Pending). The IgnoredDuringExecution suffix means the rule is not re-evaluated if node labels change after the Pod is running.
- Use Case: Ensuring a Pod with GPU-accelerated workloads only runs on nodes with specific GPU hardware labels.
- Expression Types: Uses
nodeSelectorTermswithmatchExpressionsfor flexible label matching (e.g.,In,NotIn,Exists,DoesNotExist,Gt,Lt).
PreferredDuringSchedulingIgnoredDuringExecution (Soft Affinity)
This rule type defines preferences, not requirements. The scheduler tries to satisfy them but will schedule the Pod elsewhere if not possible. Each preference has a weight (1-100) to indicate its relative importance compared to other preferences.
- Use Case: Preferring nodes in a specific availability zone or with a certain instance type for performance, while allowing fallback.
- Scheduler Scoring: The scheduler scores nodes based on how well they match these preferences; the node with the highest cumulative weight score is preferred.
Label Selector Operators
Node affinity rules use powerful label selector operators within matchExpressions to define complex constraints beyond simple equality.
In,NotIn: Check if a label's value is in (or not in) a set of strings.Exists,DoesNotExist: Check for the presence or absence of a label key, regardless of its value.Gt(Greater than),Lt(Less than): Compare label values as integers. Useful for versions or capacity (e.g.,"memory": "Gt 8"for nodes with >8GB).
Topology Spread Constraints (Complementary Feature)
While node affinity attracts Pods to certain nodes, topology spread constraints work to distribute Pods evenly across failure domains like zones, hosts, or regions. They are crucial for high availability.
- Key Fields:
maxSkewdefines the degree of imbalance allowed,topologyKeyis the node label defining the domain (e.g.,topology.kubernetes.io/zone), andwhenUnsatisfiabledictates action if spread can't be met. - Combined Use: Use node affinity to select a pool of suitable nodes, then use topology spread to distribute Pods evenly within that pool.
Anti-Affinity & Inter-Pod Affinity
Node affinity governs Pod-to-Node relationships. Pod affinity/anti-affinity governs Pod-to-Pod relationships, scheduling based on the labels of other Pods already running on a node.
- Pod Affinity: Attract Pods to nodes running other Pods with matching labels (e.g., co-locate a web server with its cache for low latency).
- Pod Anti-Affinity: Repel Pods from nodes running other Pods with matching labels (e.g., spread replicas of the same application across different nodes for resilience).
- Namespaces: Rules can be scoped within a namespace or across all namespaces.
How Node Affinity Works
Node affinity is a Kubernetes scheduling feature that constrains which nodes a Pod can be placed on, based on labels on the node, allowing rules to be expressed as either hard requirements or soft preferences.
Node affinity is a Kubernetes scheduling feature that constrains which nodes a Pod can be placed on, based on labels on the node, allowing rules to be expressed as either hard requirements or soft preferences. It provides a more expressive and powerful alternative to the older nodeSelector by supporting operators like In, NotIn, Exists, and DoesNotExist. This enables fine-grained control over Pod placement, which is critical for Edge AI Orchestration where workloads must be pinned to specific hardware or geographic locations.
Rules are defined under spec.affinity.nodeAffinity within a Pod specification. RequiredDuringSchedulingIgnoredDuringExecution defines hard constraints that must be met for scheduling. PreferredDuringSchedulingIgnoredDuringExecution defines soft preferences that the scheduler will attempt to satisfy but not guarantee. This mechanism is foundational for heterogeneous fleet orchestration, ensuring AI models are scheduled onto nodes with the necessary Neural Processing Unit (NPU) acceleration or specific sensor hardware.
Common Use Cases and Examples
Node affinity is a critical tool for ensuring AI workloads are scheduled onto nodes with the appropriate hardware, software, or location characteristics. Below are key scenarios where it is applied in edge AI architectures.
Co-location for Low-Latency Communication
Node affinity is used to co-locate interdependent microservices or AI pipeline components on the same node or set of nodes to reduce inter-process communication latency and network hops.
- Example: A real-time speech processing pipeline consists of an audio preprocessing Pod and an inference Pod. Both have affinity for nodes labeled
node-type: high-memory-io. This ensures the heavy data exchange between containers happens via local Unix sockets or shared memory, not the network. - Benefit: Critical for latency-sensitive edge AI applications like autonomous systems or industrial control, where microseconds matter.
Software or Kernel Requirement Matching
AI workloads may have specific dependencies on the host's operating system, kernel version, or installed libraries (e.g., a specific CUDA version). Node affinity ensures Pods land on nodes with compatible software environments.
- Example Rule: A Pod compiled with AVX-512 instructions requires a node with the label
kernel-features: avx512. - Edge AI Context: A model compiled for a specific Edge AI compiler toolchain (e.g., Apache TVM, NVIDIA TensorRT) may need to run on a node where that runtime is pre-installed and verified (
runtime: tensorrt-8.6).
Cost and Resource Optimization
Node affinity can express preferences (preferredDuringSchedulingIgnoredDuringExecution) to guide the scheduler toward optimal nodes, improving cluster efficiency. This is a soft rule the scheduler will try to satisfy but not guarantee.
- Example: Prefer scheduling a batch inference job onto nodes in a cost-optimized availability zone (
preference: zone-cost-optimized). - Example: Prefer nodes with SSD storage (
disk-type: ssd) for models that require frequent checkpointing or large embedding cache loads. - Benefit: Allows the scheduler to make intelligent placement decisions that reduce operational expenses and improve performance without causing Pod scheduling failures.
Node Affinity vs. Related Scheduling Features
A comparison of Kubernetes features used to influence Pod placement onto specific nodes, highlighting their distinct mechanisms, enforcement levels, and primary use cases.
| Scheduling Feature | Node Affinity | Node Selector | Taints & Tolerations | Pod Topology Spread Constraints |
|---|---|---|---|---|
Primary Purpose | Attract Pods to nodes based on flexible label matching rules. | Simple, hard requirement to schedule Pods on nodes with specific labels. | Repel Pods from nodes unless they explicitly tolerate the node's taint. | Control the spread of Pods across failure domains (e.g., zones, hosts) for high availability. |
Rule Type | Hard requirements (requiredDuringSchedulingIgnoredDuringExecution) or soft preferences (preferredDuringSchedulingIgnoredDuringExecution). | Hard requirement only. | Hard repulsion (NoSchedule), soft repulsion (PreferNoSchedule), or eviction (NoExecute). | Hard constraints (whenUnsatisfiable: DoNotSchedule) or soft skew optimization. |
Expression Language | Rich, with operators (In, NotIn, Exists, DoesNotExist, Gt, Lt) and logical AND across multiple matchExpressions. | Simple equality-based key-value pairs. | Key-value pairs with an effect (NoSchedule, PreferNoSchedule, NoExecute). Tolerations match taints with operators (Equal, Exists). | Defined by topologyKey (e.g., kubernetes.io/hostname, topology.kubernetes.io/zone) and maxSkew to limit imbalance. |
Enforcement Level | Configurable: required (must) or preferred (should). | Must (required). | Node-centric: Taint effect dictates enforcement (must not, should not, or evict). | Configurable: DoNotSchedule (must) or ScheduleAnyway (should) when constraints can't be met. |
Use Case in Edge AI | Pin a GPU-accelerated inference Pod to nodes with specific GPU models or firmware versions. | Ensure a Pod only runs on nodes labeled with 'arch: arm64' in a heterogeneous edge cluster. | Reserve master/control plane nodes or nodes undergoing maintenance; allow only system Pods with tolerations. | Spread replicas of an edge AI service across different physical racks (failure domains) to ensure resilience. |
Interaction with Other Features | Can be combined with Pod anti-affinity and topology spread constraints for complex placement. | Functionally a subset of node affinity's requiredDuringScheduling rules. Superseded by node affinity for complex needs. | Works in conjunction with affinity/selector rules. A Pod must satisfy both its own placement rules and tolerate node taints. | Often used with node affinity to achieve placement within a zone followed by spreading across hosts within that zone. |
Dynamic Updates | Node label changes do not affect already-running Pods (IgnoredDuringExecution). Pods are not rescheduled. | Node label changes do not affect already-running Pods. Pods are not rescheduled. | Adding a NoExecute taint evicts non-tolerating Pods. Changing other taint effects affects only new scheduling decisions. | Changes to constraints or topology do not affect already-running Pods. Only new Pods are scheduled under the new rules. |
Frequently Asked Questions
Node affinity is a core Kubernetes scheduling feature used to place Pods on specific nodes. These FAQs clarify its purpose, mechanics, and role in Edge AI orchestration.
Node affinity is a Kubernetes scheduling feature that constrains which nodes a Pod can be placed on, based on labels attached to the nodes, allowing rules to be expressed as either hard requirements (requiredDuringSchedulingIgnoredDuringExecution) or soft preferences (preferredDuringSchedulingIgnoredDuringExecution). It provides a more expressive and powerful alternative to the older nodeSelector by supporting complex logical operators like In, NotIn, Exists, and DoesNotExist. This is critical for Edge AI orchestration, where workloads must be pinned to nodes with specific hardware (e.g., a Neural Processing Unit), geographic location, or security posture to meet latency, performance, and compliance requirements.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Node affinity is a core component of the Kubernetes scheduler. These related concepts define the broader ecosystem for controlling workload placement and cluster management.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us