A DaemonSet is an object which ensures that there is a copy of a pod running on each node. This type of object is commonly used to deploy pods which provide a management service, such as log collection daemons or monitoring daemons to provide data to a solution such as Prometheus.
The scheduler places a copy of the pod specified in a DaemonSet on all eligible nodes within the cluster.
The manifest for a DaemonSet is very similar to that of a Deployment. There are a few significant differences to be aware of:
The spec.template.RestartPolicy field must have a value of ‘Always’ or not be specified. If the field is not present in the manifest, the pod has a restart policy of ‘Always’.
There is no field for spec.replicas as DaemonSet pods run on all nodes.
The fields spec.template.spec.nodeSelector and spec.template.spec.tolerations can be used to control scheduling with labels and taints.
The above manifest schedules a pod on each eligible node in the cluster.
The manifest did not include any taint tolerations; therefore, the scheduler did not place pods on masters.
Updating the manifest field spec.template.spec.tolerations enables scheduling of pods on masters.
There might be a use case to run a service provided by a daemon set to only a subset of nodes within the cluster. Node scheduling behaviour is the same as with Pod and Deployment configurations.
The manifest field spec.template.spec has been updated with a nodeSelector configuration and labels have been placed on two of the 3 nodes.
DaemonSets and Deployments have a lot in common with a few essential differences. DaemonSets fill the use case of running a service all relevant nodes and auto-scale based on the number of relevant nodes within the cluster.