Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
K8s Workloads Kubernetes Kubernetes: From Zero to Production Module 3 - Pods and Workloads

DaemonSets - Running a Pod on Every Node

Reviewed & accurate
AI Summary

What You Will Learn

Intermediate

  • What a DaemonSet is
  • When to use it
  • How it differs from Deployment

A DaemonSet ensures that a copy of a Pod runs on every node (or selected nodes). When a new node joins the cluster, the DaemonSet automatically places a Pod on it.

DeploymentDaemonSet
N replicas anywhere1 Pod per node
Scale by changing replicasScale by adding nodes
Best for: web apps, APIsBest for: node-level services

Common Use Cases

  • Log collection: Fluentd/Fluent Bit on every node
  • Monitoring: Prometheus Node Exporter on every node
  • Network plugin: Calico, Weave on every node
  • Storage daemon: Ceph, GlusterFS on storage nodes
daemonset.yamlyaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: log-collector
spec:
  selector:
    matchLabels:
      app: log-collector
  template:
    metadata:
      labels:
        app: log-collector
    spec:
      containers:
      - name: fluentd
        image: fluentd:latest
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      volumes:
      - name: varlog
        hostPath:
          path: /var/log

Practical Exercise

Create a DaemonSet YAML
Apply: kubectl apply -f daemonset.yaml
Check: kubectl get pods - should be 1 per node
Check: kubectl get daemonsets
Add a node (if using minikube: minikube node add)

Key Takeaways

  • DaemonSet: 1 Pod per node (automatically).
  • New node = DaemonSet puts a Pod on it.
  • Use for: log collection, monitoring, network plugins.
  • Deployment = N replicas anywhere. DaemonSet = 1 per node.
  • Scale by adding nodes, not changing replicas.
Previously: Lesson 15 covered ReplicaSets.
Today: You learned: One Pod per node - for system services.
Next: Lesson 17 covers StatefulSets.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments