What is a DaemonSet?
- Docker & Kubernetes course
- Advanced
- Lesson 19/70
- 4 min
Learn that a DaemonSet runs a Pod on every node.
What is a DaemonSet?
A DaemonSet runs one copy of a pod on every node in the cluster (or on selected nodes). No replica count is written; when a node is added, a pod is placed on the new node automatically, and when a node is removed its pod goes too.
$ kubectl get ds -A
NAMESPACE NAME DESIRED CURRENT READY NODE SELECTOR
kube-system kube-proxy 3 3 3 kubernetes.io/os=linux
izleme node-exporter 3 3 3 <none>kube-proxy and network plugins (Calico, Cilium) also run as DaemonSets.
The difference from a Deployment
A Deployment says "N replicas, wherever"; the scheduler may put several replicas on the same node. A DaemonSet says "exactly one copy on every node". For node-specific jobs (watching the node's disk, logs, network), a DaemonSet is the right choice:
Deployment (replicas: 3): worker-1: 2 pods worker-2: 1 pod worker-3: 0 pods
DaemonSet: worker-1: 1 pod worker-2: 1 pod worker-3: 1 podPractice Find the DaemonSets
Write two commands: list the DaemonSets in all namespaces; list the pods labelled app=node-exporter in the izleme namespace in wide format (with the node column).
Starter code
# buraya yazSample solution
kubectl get ds -A
kubectl get pods -n izleme -l app=node-exporter -o wideExpected output
NAMESPACE NAME DESIRED CURRENT READY kube-system kube-proxy 3 3 3 izleme node-exporter 3 3 3 NAME READY STATUS IP NODE node-exporter-4k2lp 1/1 Running 192.168.49.2 control-plane node-exporter-9xq7z 1/1 Running 192.168.49.3 worker-1 node-exporter-m3n8r 1/1 Running 192.168.49.4 worker-2
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does a DaemonSet do when a fourth node is added to a 3-node cluster?
- Nothing; replicas must be changed
- It restarts all pods
- It errors
- It automatically places a pod on the new node Correct answer
Explanation: The DESIRED value equals the number of eligible nodes.
2 List the DaemonSets with the abbreviation.
kubectl get ____ -A
kubectl get ds -A
Explanation: ds is the abbreviation of daemonsets.
3 Match.
| Term | Meaning |
|---|---|
DaemonSet |
One pod per node |
Deployment |
N replicas, anywhere |
DESIRED |
Eligible node count |
kube-proxy |
A DaemonSet example |