Middle
What is the practical use of DaemonSet in Kubernetes?
sobes.tech AI
Answer from AI
A DaemonSet ensures that a copy of a Pod is always running on each node of a Kubernetes cluster or on a subset of nodes matching specified criteria. This is useful for deploying:
- Log collectors: Agents like Fluentd or Logstash for collecting logs from each node.
- Monitoring agents: Metric exporters such as Node Exporter for Prometheus, for collecting metrics from nodes.
- System daemons: For example, kube-proxy to provide network functions on each node or storage agents.
Advantages of DaemonSet:
- Automatic deployment of Pods on new nodes.
- Automatic removal of Pods when a node is deleted.
- Guarantee of an instance on each target node.
Example of a DaemonSet definition:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-logging
labels:
app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-logging
template:
metadata:
labels:
name: fluentd-logging
spec:
containers:
- name: fluentd
image: fluentd:latest
# ... other container settings