CodeBlanks Logo Icon CodeBlanks

Summary - DaemonSet

Combine YAML and nodeSelector to write a DaemonSet.

Summary: DaemonSet

In this group:

  • A DaemonSet runs exactly one pod on each eligible node; when a node is added/removed, the pod is added/removed too.
  • YAML: apps/v1, kind: DaemonSet, selector + template; there is no replicas.
  • nodeSelector/nodeAffinity select nodes; tolerations allow tainted nodes.
  • Uses: log collection, monitoring, networking, storage and security agents; resource limits multiply with the node count.
  • Updates: RollingUpdate (maxUnavailable) or OnDelete; the rollout commands work.
kubectl get ds -A
kubectl rollout status ds/node-exporter -n izleme

Practice A collector on every node

Write a DaemonSet template's spec section (starting with spec:): under tolerations, key: node-role.kubernetes.io/control-plane, operator: Exists, effect: NoSchedule; container named fluent-bit, image fluent/fluent-bit:3.1.

Starter code

terminal
# buraya yaz

Sample solution

terminal
spec:
  tolerations:
    - key: node-role.kubernetes.io/control-plane
      operator: Exists
      effect: NoSchedule
  containers:
    - name: fluent-bit
      image: fluent/fluent-bit:3.1

Expected output

daemonset.apps/fluent-bit configured
NAME         DESIRED   CURRENT   READY
fluent-bit   3         3         3

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 If a log-collector DaemonSet doesn't run on the control-plane node, what is the likely cause?

  • The image is wrong
  • The namespace is wrong
  • There's no toleration for the NoSchedule taint on the node Correct answer
  • replicas is missing

Explanation: Control-plane nodes are tainted by default.

2 Allow the taint.

Question
      ____:
        - key: node-role.kubernetes.io/control-plane
          operator: Exists
          effect: NoSchedule
Answer
      tolerations:
        - key: node-role.kubernetes.io/control-plane
          operator: Exists
          effect: NoSchedule

Explanation: tolerations let a pod be placed on a tainted node.

3 Match.

Term Meaning
DaemonSet Per node
nodeSelector Node selection
tolerations Taint allowance
OnDelete Controlled update

All lessons in Advanced