Kubernates notes 9 Demon Set

In Kubernetes, a DaemonSet is a type of workload resource that ensures a copy of a specific pod runs on all (or a subset of) nodes in a cluster. DaemonSets are typically used for system-level or background services that need to run on every node, such as log collectors, monitoring agents, or network proxies.

Key Characteristics of DaemonSet:

  1. Pod Distribution: Ensures that a pod is running on all nodes, or a specific subset of nodes, based on labels or taints.
  2. Automatic Pod Management: When new nodes are added to the cluster, the DaemonSet automatically schedules the pod on the new nodes.
  3. Scaling: Does not scale in the same way as Deployments or StatefulSets, since its purpose is to run one pod per node, not to scale the number of pods per node.

Use Cases:

  • Monitoring agents: Tools like Prometheus node exporters or Fluentd that need to run on each node.
  • Log collection: Running agents like Filebeat or Fluentd on each node to collect logs.
  • Network proxies: DaemonSets can be used for network-related tasks, like a CNI plugin or service mesh proxy.

Example:

Here’s a simple example of a DaemonSet YAML:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: my-daemonset
spec:
  selector:
    matchLabels:
      name: my-daemonset
  template:
    metadata:
      labels:
        name: my-daemonset
    spec:
      containers:
      - name: my-container
        image: my-image:latest

This DaemonSet ensures that a pod with the container my-image:latest runs on every node in the cluster.

Let me know if you’d like more details!