π§ Concept 11: DaemonSet (Node-level Workloads π―)




π 1. Core Idea (1-line)
π DaemonSet ensures that a Pod runs on EVERY node in the cluster
π§ 2. Why DaemonSet Exists (VERY IMPORTANT β οΈ)
Normal controllers (Deployment, ReplicaSet):
- Run specific number of pods (e.g., 3, 5)
But sometimes you need:
π 1 pod per node
π‘ 3. Use Cases (REAL-WORLD π₯)
DaemonSet is used for:
-
π Monitoring agents (Prometheus node exporter)
-
π§Ύ Logging agents (Fluentd, Logstash)
-
π Security agents
-
π Networking (CNI plugins)
π Basically: node-level services
βοΈ 4. How It Works
-
New node added β pod automatically deployed
-
Node removed β pod removed
π Fully automatic
π₯ 5. Example Scenario
Cluster:
- 3 nodes
DaemonSet:
π Will run 3 pods (1 per node)
Add 1 node:
π Now 4 pods automatically
π¦ 6. Example YAML
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-monitor
spec:
selector:
matchLabels:
app: monitor
template:
metadata:
labels:
app: monitor
spec:
containers:
- name: monitor
image: node-exporterπ§ 7. Key Difference (IMPORTANT π₯)
| Feature | Deployment | DaemonSet |
|---|---|---|
| Pod count | Fixed number | One per node |
| Scaling | Manual | Auto with nodes |
| Use case | Apps | Node services |
π₯ 8. Real-world DevOps Insight
In your stack (SigNoz, Prometheus π):
π Node exporter runs via DaemonSet
π Collects metrics from each node
β οΈ 9. Advanced Concept (IMPORTANT)
π You can control where pods run using:
-
Node selectors
-
Taints & tolerations
Example:
- Run only on GPU nodes π₯
β‘ 10. CKA Commands
kubectl get daemonsets
kubectl describe daemonset <name>πΌ 11. Interview Answer
π βDaemonSet ensures that a copy of a Pod runs on all or selected nodes in a Kubernetes cluster, commonly used for logging, monitoring, and node-level services.β
π§ 12. Memory Trick
π Deployment = count-based π
π DaemonSet = node-based π₯οΈ
π₯ 13. Common Mistakes
β Using Deployment for node agents
β Forgetting DaemonSet auto-scales with nodes
β Not using tolerations for special nodes
π Next Step
Bol:
π βnextβ
Then we go to:
π₯ Concept 12: Jobs & CronJobs (Batch + Scheduled Workloads π―)