0
0
Kubernetesdevops~10 mins

DaemonSets for per-node workloads in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - DaemonSets for per-node workloads
Create DaemonSet YAML
kubectl apply DaemonSet
Kubernetes Scheduler
DaemonSet Controller creates Pod on each Node
Pods run on all current Nodes
New Node joins Cluster?
Yes
DaemonSet Controller adds Pod to new Node
Pods run on all Nodes including new one
Node removed?
Yes
Pod on removed Node deleted
DaemonSet maintains one Pod per Node
This flow shows how a DaemonSet ensures one Pod runs on each node, including new nodes joining the cluster.
Execution Sample
Kubernetes
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-monitor
spec:
  selector:
    matchLabels:
      name: node-monitor
  template:
    metadata:
      labels:
        name: node-monitor
    spec:
      containers:
      - name: monitor
        image: busybox
        command: ["sh", "-c", "while true; do echo monitoring; sleep 30; done"]
This YAML creates a DaemonSet named node-monitor that runs a simple monitoring container on every node.
Process Table
StepActionResultPods per Node
1Apply DaemonSet YAML with kubectlDaemonSet resource created0
2DaemonSet Controller detects DaemonSetStarts creating Pods0
3Create Pod on Node1Pod running on Node1Node1:1
4Create Pod on Node2Pod running on Node2Node1:1, Node2:1
5New Node3 joins clusterDaemonSet Controller creates Pod on Node3Node1:1, Node2:1, Node3:1
6Node2 removed from clusterPod on Node2 deletedNode1:1, Node3:1
7DaemonSet maintains Pods on all nodesPods running on all current nodesNode1:1, Node3:1
💡 DaemonSet ensures exactly one Pod per node; stops when no more nodes exist or DaemonSet deleted.
Status Tracker
VariableStartAfter Step 3After Step 4After Step 5After Step 6Final
Pods per Node{}{"Node1":1}{"Node1":1, "Node2":1}{"Node1":1, "Node2":1, "Node3":1}{"Node1":1, "Node3":1}{"Node1":1, "Node3":1}
Key Moments - 3 Insights
Why does the DaemonSet create a new Pod when a new node joins?
Because the DaemonSet controller watches the cluster nodes and ensures one Pod per node. When a new node appears (see Step 5), it creates a Pod there automatically.
What happens to Pods on nodes that are removed from the cluster?
Pods on removed nodes are deleted (Step 6) because the node no longer exists. The DaemonSet controller updates the Pod list accordingly.
Can a DaemonSet create more than one Pod per node?
No. The DaemonSet ensures exactly one Pod per node, as shown in the Pods per Node column in the execution table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, how many Pods are running after Step 4?
A1 Pod on Node1 and 1 Pod on Node2
B1 Pod on Node1
C1 Pod on Node1, Node2, and Node3
DNo Pods running yet
💡 Hint
Check the 'Pods per Node' column at Step 4 in the execution table.
At which step does the DaemonSet add a Pod to a new node?
AStep 4
BStep 5
CStep 3
DStep 6
💡 Hint
Look for when Node3 first appears with a Pod in the execution table.
If Node2 is removed, what happens to the Pod on Node2?
AIt remains running
BIt moves to another node
CIt is deleted
DIt duplicates on Node1
💡 Hint
See Step 6 in the execution table where Node2 is removed.
Concept Snapshot
DaemonSet runs one Pod on each node in a Kubernetes cluster.
Apply a DaemonSet YAML with kubectl to create it.
Pods are automatically added to new nodes.
Pods on removed nodes are deleted.
Ensures per-node workload consistency.
Full Transcript
A DaemonSet in Kubernetes ensures that a specific Pod runs on every node in the cluster. When you create a DaemonSet using kubectl apply, the DaemonSet controller watches the cluster nodes and creates one Pod per node. If a new node joins, the controller adds a Pod there automatically. If a node is removed, the Pod on that node is deleted. This way, the DaemonSet keeps exactly one Pod running on each node, useful for per-node tasks like monitoring or logging.