What's the purpose of Kubernetes DaemonSet when replication controllers have node anti-affinity

1/13/2017

DaemonSet is a Kubernetes beta resource that can ensure that exactly one pod is scheduled to a group of nodes. The group of nodes is all nodes by default, but can be limited to a subset using nodeSelector or the Alpha feature of node affinity/anti-affinity.

It seems that DaemonSet functionality can be achieved with replication controllers/replica sets with proper node affinity and anti-affinity.

Am I missing something? If that's correct should DaemonSet be deprecated before it even leaves Beta?

-- Pyramid Newbie
kubernetes

1 Answer

1/14/2017

As you said, DaemonSet guarantees one pod per node for a subset of the nodes in the cluster. If you use ReplicaSet instead, you need to

  1. use the node affinity/anti-affinity and/or node selector to control the set of nodes to run on (similar to how DaemonSet does it).
  2. use inter-pod anti-affinity to spread the pods across the nodes.
  3. make sure the number of pods > number of node in the set, so that every node has one pod scheduled.

However, ensuring (3) is a chore as the set of nodes can change over time. With DaemonSet, you don't have to worry about that, nor would you need to create extra, unschedulable pods. On top of that, DaemonSet does not rely on the scheduler to assign its pods, which makes it useful for cluster bootstrap (see How Daemon Pods are scheduled).

See the "Alternative to DaemonSet" section in the DaemonSet doc for more comparisons. DaemonSet is still the easiest way to run a per-node daemon without external tools.

-- Yu-Ju Hong
Source: StackOverflow