DaemonSets

Ein DaemonSet stellt sicher, dass auf jedem Node im Cluster genau eine Instanz eines bestimmten Pods läuft. Typische Anwendungsfälle: Log-Sammler, Monitoring-Agenten, Netzwerk-Plugins.

Beispiel: Log-Sammler (Alloy)

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: alloy
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: alloy
  template:
    metadata:
      labels:
        app: alloy
    spec:
      tolerations:
      - key: node-role.kubernetes.io/control-plane
        effect: NoSchedule
      containers:
      - name: alloy
        image: grafana/alloy:latest
        volumeMounts:
        - name: varlog
          mountPath: /var/log
          readOnly: true
        - name: config
          mountPath: /etc/alloy
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: config
        configMap:
          name: alloy-config

Befehle

kubectl apply -f alloy-daemonset.yaml
kubectl get daemonsets -n monitoring
kubectl get pods -n monitoring -o wide   # ein Pod pro Node
kubectl describe daemonset/alloy -n monitoring

DaemonSets im Cluster

k3s bringt eigene DaemonSets mit:

kubectl get daemonsets -A
# kube-system   svclb-traefik    (Traefik Service Load Balancer)

Unterschied zu Deployments

  Deployment DaemonSet
Replikas konfigurierbar 1 pro Node
Scheduling beliebige Nodes alle Nodes
Anwendungsfall Stateless Apps Node-spezifische Dienste