<commit_before>:context: nodes-pods-daemonsets
[id="nodes-pods-daemonsets"]
=  Running background tasks on nodes automatically with daemonsets in {product-title}
include::modules/common-attributes.adoc[]

toc::[]





As an administrator, you can create and use DaemonSets to run replicas of a pod on specific or all nodes in an {product-title} cluster.

A DaemonSet ensures that all (or some) nodes run a copy of a pod. As nodes are added to the cluster, pods are added to the cluster. 
As nodes are removed from the cluster, those pods are removed through garbage collection. Deleting a DaemonSet will clean up the Pods it created.

You can use daemonsets to create shared storage, run a logging pod on every node in
your cluster, or deploy a monitoring agent on every node.

For security reasons, only cluster administrators can create daemonsets.

For more information on daemonsets, see the link:http://kubernetes.io/docs/admin/daemons/[Kubernetes documentation].

[IMPORTANT]
====
Daemonset scheduling is incompatible with project's default node selector.
If you fail to disable it, the daemonset gets restricted by merging with the
default node selector. This results in frequent pod recreates on the nodes that
got unselected by the merged node selector, which in turn puts unwanted load on
the cluster.
====

// The following include statements pull in the module files that comprise
// the assembly. Include any combination of concept, procedure, or reference
// modules required to cover the user story. You can also include other
// assemblies.

include::modules/nodes-pods-daemonsets-creating.adoc[leveloffset=+1]<commit_msg>Add ScheduleDSPods<commit_after>:context: nodes-pods-daemonsets
[id="nodes-pods-daemonsets"]
=  Running background tasks on nodes automatically with daemonsets in {product-title}
include::modules/common-attributes.adoc[]

toc::[]





As an administrator, you can create and use DaemonSets to run replicas of a pod on specific or all nodes in an {product-title} cluster.

A DaemonSet ensures that all (or some) nodes run a copy of a pod. As nodes are added to the cluster, pods are added to the cluster. 
As nodes are removed from the cluster, those pods are removed through garbage collection. Deleting a DaemonSet will clean up the Pods it created.

You can use daemonsets to create shared storage, run a logging pod on every node in
your cluster, or deploy a monitoring agent on every node.

For security reasons, only cluster administrators can create daemonsets.

For more information on daemonsets, see the link:http://kubernetes.io/docs/admin/daemons/[Kubernetes documentation].

[IMPORTANT]
====
Daemonset scheduling is incompatible with project's default node selector.
If you fail to disable it, the daemonset gets restricted by merging with the
default node selector. This results in frequent pod recreates on the nodes that
got unselected by the merged node selector, which in turn puts unwanted load on
the cluster.
====

== Scheduled by default scheduler

A DaemonSet ensures that all eligible nodes run a copy of a Pod. Normally, the node that a Pod runs on is selected by the Kubernetes scheduler. However, previously daemonSet pods are created and scheduled by the DaemonSet controller. That introduces the following issues:

* Inconsistent Pod behavior: Normal Pods waiting to be scheduled are created and in Pending state, but DaemonSet pods are not created in Pending state. This is confusing to the user.
* Pod preemption is handled by default scheduler. When preemption is enabled, the DaemonSet controller will make scheduling decisions without considering pod priority and preemption.

ScheduleDaemonSetPods is enabled by default in {product-title} which lets you to schedule DaemonSets using the default scheduler instead of the DaemonSet controller, by adding the NodeAffinity term to the DaemonSet pods, instead of the .spec.nodeName term. The default scheduler is then used to bind the pod to the target host. If node affinity of the DaemonSet pod already exists, it is replaced. The DaemonSet controller only performs these operations when creating or modifying DaemonSet pods, and no changes are made to the spec.template of the DaemonSet.

nodeAffinity:
  requiredDuringSchedulingIgnoredDuringExecution:
    nodeSelectorTerms:
    - matchFields:
      - key: metadata.name
        operator: In
        values:
        - target-host-name

In addition, node.kubernetes.io/unschedulable:NoSchedule toleration is added automatically to DaemonSet Pods. The default scheduler ignores unschedulable Nodes when scheduling DaemonSet Pods.


// The following include statements pull in the module files that comprise
// the assembly. Include any combination of concept, procedure, or reference
// modules required to cover the user story. You can also include other
// assemblies.

include::modules/nodes-pods-daemonsets-creating.adoc[leveloffset=+1]
{'fraction_non_alphanumeric': 0.05113057649215726, 'fraction_numerical': 0.00040741495212874313, 'mean_word_length': 4.6371986222732495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7233094', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1210, 'n_words': 662}