October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Kubernetes Taints and Tolerations vs. Node Affinity: How to Choose

Node affinity selects nodes by labels; taints repel Pods unless tolerated. Learn when to use each and how to combine them to dedicate a node group.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use node affinity to attract or require a Pod on nodes with matching labels; use taints and tolerations to repel Pods from nodes unless they are permitted past the taint. A toleration is not a placement instruction. If you need to reserve a node group for selected workloads, combine a taint with a node label and required node affinity.

What each mechanism does

Node affinity selects from the Pod side

Node affinity is a rule on the Pod that matches node labels. With a required rule, the Pod cannot schedule unless a node matches. With a preferred rule, the scheduler favors matching nodes but may choose another eligible node. The official Kubernetes guide, Assigning Pods to Nodes, describes these options and the simpler nodeSelector alternative.

As an Amazon Associate I earn from qualifying purchases.

nodeSelector is suitable for straightforward label matching; node affinity supports more expressive required and preferred rules. If a Pod specifies both nodeSelector and node affinity, it must satisfy both.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Taints repel from the node side

A taint is applied to a node. A Pod that lacks a matching toleration can be blocked or discouraged from scheduling there, depending on the taint effect. A toleration lets the Pod pass that taint filter; it does not tell the scheduler to choose that node. The scheduler still evaluates the Pod’s other constraints and the node’s available resources. Kubernetes explains the matching and filtering behavior in Taints and Tolerations.

#1 Best Overall

Choose based on the placement outcome you need

Need Use What it does
The Pod must run on nodes with a required property, such as a hardware or zone label Required node affinity Prevents scheduling unless a node matches.
The Pod should prefer a node group but may run elsewhere Preferred node affinity Influences node selection without making the preference mandatory.
Keep ordinary workloads away from a node group A taint on those nodes Blocks or discourages Pods without matching tolerations, according to the effect.
Permit selected workloads past a taint A matching toleration on those Pods Removes the matching taint as a barrier; it does not select the node.
Reserve nodes for a workload group Taint plus label and required node affinity Repels unrelated Pods and constrains intended Pods to the labeled node group.
Evict running workloads that do not tolerate a node condition NoExecute taint Affects existing as well as new Pods; toleration settings determine whether and how long a Pod remains.

Understand the scheduling and eviction effects

Affinity: required versus preferred

  • requiredDuringSchedulingIgnoredDuringExecution is a hard scheduling requirement: if no eligible node has matching labels, the Pod cannot be scheduled.
  • preferredDuringSchedulingIgnoredDuringExecution is a preference: the scheduler tries to favor matching nodes but can choose another eligible node.
  • IgnoredDuringExecution means a later change to a node’s labels does not, by itself, evict a Pod that has already been scheduled there.

Taints: NoSchedule, PreferNoSchedule, and NoExecute

  • NoSchedule blocks new Pods that lack a matching toleration. It does not evict Pods already running on the node.
  • PreferNoSchedule asks the scheduler to avoid placing non-tolerating Pods on the node when possible; it is a soft preference, not a guarantee.
  • NoExecute affects both new and running Pods. A Pod without a matching toleration is not admitted and a running Pod can be evicted. A matching toleration with tolerationSeconds can delay eviction for the configured interval.

When a node has multiple taints, tolerations are considered against them as filters. Matching tolerations remove the corresponding taints from consideration; any remaining taint can still affect scheduling or eviction according to its effect. The Kubernetes API reference, Toleration v1, documents toleration fields and effects.

Reserve a node group for selected workloads

Neither half of the policy is enough by itself when the goal is to dedicate nodes. A taint repels workloads without the right toleration, but tolerating it does not direct the intended workload to those nodes. Required affinity selects the labeled nodes, but by itself does not repel unrelated Pods that have other ways to qualify for them.

  1. Label the intended nodes with a key and value that identify the group.
  2. Taint those nodes so workloads without the specific matching toleration are blocked or discouraged, using the effect that fits your policy.
  3. Add the matching toleration only to the intended workloads so they can pass that taint.
  4. Add required node affinity to those workloads using the node label, so they are constrained to the intended group.

This combines exclusion (the taint) with selection (the affinity), the dedicated-node pattern described in the Kubernetes node assignment guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check security-sensitive isolation separately

For security or regulatory isolation, an ordinary mutable node label alone should not be treated as a security boundary. Kubernetes recommends using labels that the kubelet cannot modify and configuring the Node authorizer and NodeRestriction admission plugin as documented in its node assignment guidance. The label and access-control setup must support the trust boundary you intend to enforce.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot a Pod that remains pending

A toleration only clears a matching taint barrier; it does not prove that any node is a valid destination. Check the full set of scheduling conditions:

  • Do the candidate nodes have the labels required by the Pod’s node affinity or nodeSelector?
  • Does each taint have a matching toleration with the needed key, value, operator, and effect?
  • Are there other taints left unmatched that still affect placement?
  • Do candidate nodes have capacity for the Pod’s resource requests?
  • Do the Pod’s other scheduling constraints allow any candidate node?

Actual placement also depends on the Kubernetes version and scheduler configuration in use; verify behavior against the cluster you operate.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.