Course contentsShow
← Cloud and Infrastructure
Lesson 1187 of 2,98923. Kubernetes WorkloadsFree lesson

DaemonSet Scheduling and Node Selection

Controlling DaemonSet pod placement using nodeSelectors, affinity, and tolerations.

DaemonSet Scheduling and Node Selection

You'll learn how to control which nodes receive DaemonSet pods using scheduling rules.

Why Control DaemonSet Placement?

By default, a DaemonSet runs on every node in your cluster. But what if you only need a monitoring agent on GPU-equipped nodes, or a logging collector on production-labeled nodes only? Kubernetes gives you three main tools to be selective: nodeSelectors, affinity rules, and tolerations.

Think of it like mail delivery routes: instead of delivering to every house (every node), you can specify "only houses on streets with even numbers" (selected nodes).

The Three Control Mechanisms

nodeSelector is the simplest approach. You add a label constraint to the DaemonSet pod template, and it only runs on nodes with matching labels:

nodeSelector:
  disktype: ssd

This runs the DaemonSet only on nodes labeled disktype=ssd.

Affinity provides more expressive rules, like "prefer nodes in zone us-east-1a" or "avoid nodes with high memory pressure." It supports complex logic beyond simple equality.

Tolerations work differently—they let your DaemonSet pods tolerate node taints. Nodes might be tainted to repel regular workloads (like master nodes or specialized hardware). Tolerations say "this pod can run there anyway":

tolerations:
- key: node-role.kubernetes.io/master
  effect: NoSchedule

Together, these tools give you surgical precision: nodeSelector for basic filtering, affinity for sophisticated preferences, and tolerations to override node restrictions.

Key Takeaway: DaemonSets don't have to run everywhere—use nodeSelector for simple label matching, affinity for complex placement logic, and tolerations to run on otherwise restricted nodes.