✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Kubernetes DaemonSet Resource Management

Kubernetes DaemonSet Resource Management ensures consistent node-level service operation through automated pod deployment and resource allocation strategies.

Kubernetes DaemonSet Resource Management is the practice of sizing CPU and memory requests and limits for a DaemonSet's Pod template with specific attention to the fact that a single resource configuration is multiplied across every node the daemon covers, making resource decisions here carry a cluster-wide capacity impact that a comparable decision for a Deployment replica would not. A resource request that seems modest in isolation — say, 200m CPU and 256Mi memory — becomes a meaningfully large aggregate reservation once multiplied across hundreds of nodes, competing directly with the capacity available for application workloads on every single one of them.

This multiplication effect is the defining characteristic that separates DaemonSet resource management from resource management for any replica-count-based controller, and it shapes nearly every practical decision about how daemon workloads should be sized, monitored, and constrained.


Sizing Requests and Limits

Conservative Requests as the Default Posture

Because a DaemonSet's request is reserved on every eligible node regardless of whether the daemon is actually using that much at any given moment, requests are typically sized to reflect the daemon's steady-state baseline consumption rather than its worst-case peak, trusting limits (and the resulting ability to burst up to them) to absorb occasional spikes without over-reserving capacity that then sits unused on every node.

resources:
  requests:
    cpu: "50m"
    memory: "64Mi"
  limits:
    cpu: "200m"
    memory: "256Mi"

Avoiding Limits That Are Too Tight

Setting memory limits too close to typical usage risks OOM-killing the daemon under normal, brief spikes (a log collector momentarily buffering a burst of log lines, for instance), which then triggers Pod restarts across potentially many nodes simultaneously if the spike is cluster-wide rather than isolated to one node — daemon memory limits are generally given more headroom above typical usage than a comparably-sized application container might need, specifically to avoid correlated restarts across the fleet.


Aggregate Capacity Impact

Calculating Cluster-Wide Reservation

The total reserved capacity for a DaemonSet is simply its per-Pod request multiplied by desiredNumberScheduled. A daemon requesting 100m CPU across a 200-node cluster reserves 20 full CPU cores cluster-wide — a number worth calculating explicitly before deploying a new daemon, rather than reasoning only about the seemingly small per-Pod figure.

kubectl get daemonset codartium-log-agent -o jsonpath='{.status.desiredNumberScheduled}'
# multiply by per-Pod CPU/memory request to estimate aggregate cluster impact

Interaction with Node Autoscaling

Because DaemonSet Pods are present on every node regardless of application workload density, they factor into cluster autoscaler decisions and per-node bin-packing calculations on every single node — a cluster running several resource-hungry daemons effectively reduces the allocatable capacity available to application workloads across the entire fleet, which should be accounted for when sizing node instance types or setting autoscaler thresholds.


Monitoring Daemon Resource Consumption

Per-Node Usage Comparison

kubectl top pods -l app=codartium-log-agent --sort-by=cpu
kubectl top pods -l app=codartium-log-agent --sort-by=memory

Comparing actual usage across all instances of the same daemon (which should, in principle, behave similarly on every node) surfaces outlier nodes where the daemon is consuming disproportionately more resources than its peers — often indicative of a node-specific condition (a larger volume of log traffic, more Pods scheduled there generating more events to process) rather than a daemon bug affecting the fleet uniformly.

Correlating Daemon Resource Growth with Cluster Growth

Some daemons (particularly log and metrics collectors) have resource needs that scale not just with the node but with the number of Pods scheduled onto that node — a log collector on a densely packed node processes more log volume than one on a sparsely packed node. Resource requests for such daemons benefit from being informed by the busiest nodes in the cluster rather than an average, to avoid under-provisioning on exactly the nodes where the daemon matters most.


QoS Class Considerations

Guaranteed QoS for Critical Daemons

Setting requests equal to limits for both CPU and memory places a daemon Pod in the Guaranteed QoS class, which the kubelet protects most strongly from eviction under node resource pressure — an appropriate choice for daemons whose continued operation is critical to the node's basic functioning (a CNI plugin, a CSI node component), since these are precisely the workloads that should be the last, not the first, to be evicted when a node runs low on resources.

resources:
  requests:
    cpu: "100m"
    memory: "128Mi"
  limits:
    cpu: "100m"
    memory: "128Mi"

Example

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: codartium-resource-example
spec:
  selector:
    matchLabels:
      app: codartium-node-agent
  template:
    metadata:
      labels:
        app: codartium-node-agent
    spec:
      containers:
        - name: agent
          image: codartium/node-agent:latest
          resources:
            requests:
              cpu: "50m"
              memory: "64Mi"
            limits:
              cpu: "150m"
              memory: "192Mi"