A DaemonSet ensures that a copy of a specific pod runs on all or some nodes in a Kubernetes cluster. It is used for running per-node workloads like monitoring or logging agents.
Click to reveal answer
intermediate
How does a DaemonSet differ from a Deployment in Kubernetes?
A Deployment manages pods that can run anywhere in the cluster and scales by number of replicas, while a DaemonSet runs exactly one pod per selected node, ensuring per-node coverage.
Click to reveal answer
beginner
Which Kubernetes resource would you use to run a logging agent on every node?
You would use a DaemonSet to run a logging agent on every node, because it guarantees one pod per node.
Click to reveal answer
intermediate
What happens to DaemonSet pods when a new node is added to the cluster?
When a new node joins the cluster, the DaemonSet automatically creates a pod on that node to maintain one pod per node.
Click to reveal answer
intermediate
Can you limit a DaemonSet to run pods only on specific nodes?
Yes, by using node selectors or node affinity rules in the DaemonSet specification, you can restrict pods to run only on certain nodes.
Click to reveal answer
What is the primary purpose of a DaemonSet in Kubernetes?
AManage persistent storage
BScale pods based on load
CControl network policies
DRun one pod on every node
✗ Incorrect
A DaemonSet runs exactly one pod on each node to handle per-node tasks.
If you add a new node to your cluster, what does the DaemonSet do?
ACreates a pod on the new node
BScales pods to zero
CDeletes pods on other nodes
DDoes nothing automatically
✗ Incorrect
DaemonSet automatically creates a pod on the new node to maintain coverage.
How can you restrict a DaemonSet to run pods only on Linux nodes?
AUse nodeSelector with OS label
BUse a Deployment instead
CSet pod replicas to zero
DUse a ConfigMap
✗ Incorrect
Using nodeSelector with the OS label limits pods to Linux nodes.
Which workload is best suited for a DaemonSet?
ADatabase cluster
BNode monitoring agent
CWeb application with variable scaling
DBatch job
✗ Incorrect
Node monitoring agents need to run on every node, so DaemonSet is ideal.
What happens if a node is removed from the cluster?
APods remain running on the removed node
BPods move to other nodes automatically
CDaemonSet pods on that node are deleted
DDaemonSet creates extra pods on remaining nodes
✗ Incorrect
When a node is removed, its DaemonSet pods are deleted with it.
Explain what a DaemonSet is and why it is useful in Kubernetes.
Think about workloads that need to run everywhere in the cluster.
You got /3 concepts.
Describe how you can control which nodes a DaemonSet runs pods on.
Consider how Kubernetes matches pods to nodes.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of a DaemonSet in Kubernetes?
easy
A. To expose services outside the cluster
B. To manage persistent storage volumes
C. To run one pod on every node in the cluster
D. To schedule batch jobs at specific times
Solution
Step 1: Understand DaemonSet functionality
A DaemonSet ensures that a copy of a pod runs on all or some nodes in the cluster.
Step 2: Compare with other Kubernetes objects
Other objects like Jobs or Services do not guarantee one pod per node; DaemonSet does.
Final Answer:
To run one pod on every node in the cluster -> Option C
Quick Check:
DaemonSet = one pod per node [OK]
Hint: DaemonSet always runs pods on all nodes [OK]
Common Mistakes:
Confusing DaemonSet with Deployment
Thinking DaemonSet manages storage
Assuming DaemonSet schedules batch jobs
2. Which of the following is the correct way to specify a DaemonSet selector in the YAML manifest?
easy
A. selector:
labels:
app: my-daemon
B. selector:
matchLabels:
app: my-daemon
C. selector:
matchExpressions:
- key: app
operator: Equals
values: [my-daemon]
D. selector:
matchLabels:
app: my-daemon
matchExpressions:
- key: tier
operator: In
values: [backend]
Solution
Step 1: Recall DaemonSet selector syntax
The selector must use matchLabels or matchExpressions under selector.
Step 2: Identify correct syntax
selector:
matchLabels:
app: my-daemon uses matchLabels correctly with key-value pairs. selector:
labels:
app: my-daemon is invalid because it uses labels instead of matchLabels. selector:
matchExpressions:
- key: app
operator: Equals
values: [my-daemon] has wrong operator case and structure. selector:
matchLabels:
app: my-daemon
matchExpressions:
- key: tier
operator: In
values: [backend] mixes both but DaemonSet selector only supports one selector type.
Final Answer:
selector:
matchLabels:
app: my-daemon -> Option B
Quick Check:
DaemonSet selector uses matchLabels [OK]
Hint: Use matchLabels under selector for DaemonSet [OK]
Common Mistakes:
Using 'labels' instead of 'matchLabels'
Incorrect operator casing in matchExpressions
Mixing matchLabels and matchExpressions in selector
3. Given this DaemonSet YAML snippet, what will happen when a new node joins the cluster?
A. A pod named log-agent will be created on the new node automatically
B. No pod will be created until manually triggered
C. The DaemonSet will fail due to missing node selector
D. Pods will be created only on nodes labeled 'log-agent'
Solution
Step 1: Understand DaemonSet behavior on new nodes
DaemonSets automatically create pods on every node that matches the selector, including new nodes joining the cluster.
Step 2: Check node selector usage
This DaemonSet has no node selector restricting nodes, so it applies to all nodes.
Final Answer:
A pod named log-agent will be created on the new node automatically -> Option A
Quick Check:
DaemonSet pods auto-create on new nodes [OK]
Hint: DaemonSet pods auto-launch on all nodes by default [OK]
Common Mistakes:
Assuming manual pod creation on new nodes
Thinking node selector is mandatory
Believing pods only run on labeled nodes
4. You created a DaemonSet but no pods are running on any node. Which of these is the most likely cause?
medium
A. The DaemonSet is created in the wrong namespace
B. The DaemonSet spec is missing the container image
C. The cluster has no nodes available
D. The pod template labels do not match the DaemonSet selector
Solution
Step 1: Check DaemonSet selector and pod template labels
DaemonSet requires the selector to match the pod template labels exactly; otherwise, pods won't be created.
Step 2: Evaluate other options
Missing container image causes pod creation failure but usually shows pod errors. No nodes means no pods but is rare. Wrong namespace means DaemonSet exists but unrelated to nodes.
Final Answer:
The pod template labels do not match the DaemonSet selector -> Option D
Quick Check:
Selector and pod labels must match [OK]
Hint: Match pod labels with selector to run DaemonSet pods [OK]
Common Mistakes:
Ignoring label mismatch between selector and template
Assuming missing image stops pod creation silently
Not verifying cluster node availability
5. You want to run a logging agent on all Linux nodes but exclude Windows nodes in your Kubernetes cluster. How should you configure the DaemonSet?
hard
A. Add a nodeSelector with kubernetes.io/os: linux in the pod spec
B. Add a tolerations for Windows taints in the pod spec
C. Set the DaemonSet selector to os: linux label
D. Use a Deployment instead of DaemonSet with node affinity
Solution
Step 1: Identify how to target Linux nodes only
Kubernetes labels nodes with kubernetes.io/os set to their OS. Using nodeSelector with kubernetes.io/os: linux restricts pods to Linux nodes.
Step 2: Evaluate other options
Tolerations are for taints, not OS filtering. Selector matches pod labels, not nodes. Deployment does not guarantee one pod per node.
Final Answer:
Add a nodeSelector with kubernetes.io/os: linux in the pod spec -> Option A
Quick Check:
Use nodeSelector to filter nodes by OS [OK]
Hint: Use nodeSelector with OS label to filter nodes [OK]
Common Mistakes:
Using selector to filter nodes instead of nodeSelector
Confusing tolerations with node filtering
Using Deployment instead of DaemonSet for per-node pods
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.