Daemon Sets

A DaemonSet ensures that all (or some) Nodes run a copy of a pod.

Difference between ReplicaSet (green) and DaemonSet (blue).
Difference between ReplicaSet (green) and DaemonSet (blue). (Source: Lukša)

Relationship with the Scheduler

A DaemonSet bypasses the Scheduler completely.

If you mark nodes as unschedulable (preventing pods from being deployed to them), a DaemonSet will still deploy pods to them.

DaemonSet descriptor

The following example will deploy luksa/ssd-monitor pods on nodes that matches the spec.template.spec.nodeSelector.

The nodes watched by the DaemonSet itself if tagged with app=ssd-monitor. (See ReplicaSet's types of selector to see how you can select the pods.)

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ssd-monitor
spec:
  # The pods watched by DaemonSet are
  # those that match "app=ssd-monitor"
  selector:
    matchLabels:
      app: ssd-monitor
  template:
    metadata:
      labels:
        app: ssd-monitor
    spec:
      # The pods that the DaemonSet will deploy to
      # matches "disk=ssd"
      nodeSelector:
        disk: ssd
      containers:
        - name: main
          image: luksa/ssd-monitor

Here's the illustration for the above case:

Deploying ssd-monitor pods on nodes with disk=ssd.
Deploying ssd-monitor pods on nodes with disk=ssd. (Source: Lukša)

Working with DaemonSets

DaemonSet's abbreviation is ds.

Creating a DaemonSet

kubectl create -f <filename>

Listing DaemonSets

kubectl get ds

Describing a DaemonSet

kubectl describe ds <daemonSetName>

Deleting a DaemonSet

kubectl delete <daemonSetName>

References