Skip to main content

Concept and Usage of DaemonSet

A DaemonSet ensures that all (or some) nodes run a copy of a Pod.
  • Whenever a new node is added to the cluster, a pod is automatically added to that node.
  • When a node is removed from the cluster, the pod is automatically removed.
DaemonSet uses the default scheduler and node affinity rules to schedule pods on nodes.
Use cases:

Logging Agent

Run a logging agent (collector) on all nodes.

Monitoring Agent

Run a monitoring agent on all nodes.

Network Services

Set up network services like firewall, load-balancer, network proxies, or VPN on all nodes.

kube-proxy

The kube-proxy component is actually deployed as a DaemonSet in Kubernetes.

DaemonSet YAML

daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: sample-daemonset
spec:
  selector:
    matchLabels:
      app: sample-agent
  template:
    metadata:
      labels:
        app: sample-agent
    spec:
      containers:
        - name: sample-monitoring-agent
          image: sample-monitoring-agent-image
kubectl get daemonsets

Build docs developers (and LLMs) love