Understanding DaemonSets in OpenShift (OCP)

What is a DaemonSet in OpenShift?

A DaemonSet is a Kubernetes workload that ensures exactly one copy of a Pod runs on every selected node in the cluster.

Unlike a Deployment, where you specify the number of replicas, a DaemonSet automatically creates and removes Pods as nodes are added or removed.

Think of a DaemonSet as “one Pod per node.”


Why DaemonSets are Important in OpenShift

Many OpenShift platform services must run on every node because they collect metrics, logs, or provide node-level networking.

For example:

                OpenShift Cluster

      ┌──────────────┬──────────────┬──────────────┐
      │              │              │
      ▼              ▼              ▼
   Worker-1       Worker-2       Worker-3
      │              │              │
      ▼              ▼              ▼
 Node Exporter   Node Exporter   Node Exporter

Each node has its own Node Exporter Pod.

If a new node joins:

Worker-4
↓
DaemonSet automatically creates
↓
Node Exporter Pod

No manual action is required.


DaemonSet vs Deployment

DeploymentDaemonSet
Fixed number of replicasOne Pod per node
Used for applicationsUsed for node services
Scheduler decides placementAutomatically targets selected nodes
Scale manuallyScales with the number of nodes
Example: Web appExample: Logging agent

Example:

Deployment

Cluster
10 Nodes
↓
Deployment replicas = 3
↓
Only 3 Pods

DaemonSet

Cluster
10 Nodes
↓
DaemonSet
↓
10 Pods
(1 on each node)

How DaemonSet Works

New Node Added
│
▼
DaemonSet Controller detects node
│
▼
Creates Pod
│
▼
Pod scheduled on new node

If a node is removed:

Node Deleted
↓
DaemonSet Pod Deleted

Real OpenShift DaemonSets

Run:

oc get daemonset -A

Typical output:

NAMESPACE NAME
openshift-monitoring node-exporter
openshift-logging collector
openshift-ovn-kubernetes ovnkube-node
openshift-multus multus
openshift-machine-config machine-config-daemon

These are all critical platform components.


1. Node Exporter

Every Node
↓
Node Exporter
↓
CPU
Memory
Disk
Filesystem
Network

Used by Prometheus for infrastructure monitoring.


2. Machine Config Daemon

MachineConfig
↓
Machine Config Operator
↓
Machine Config Daemon
↓
Every Node

The Machine Config Daemon applies operating system changes on each RHCOS node.


3. OVN-Kubernetes

Every node participates in cluster networking.

Node
↓
OVN Pod
↓
Programs Open vSwitch
↓
Pod Networking

Without it, Pods cannot communicate.


4. Vector Collector

OpenShift Logging deploys Vector as a DaemonSet.

Every Node
↓
Vector
↓
Collect container logs
↓
Loki
Splunk
Elasticsearch

Each node collects its own logs locally and forwards them.


DaemonSet Architecture

                  DaemonSet Controller
                          │
        ┌─────────────────┼─────────────────┐
        │                 │                 │
        ▼                 ▼                 ▼
     Worker-1         Worker-2         Worker-3
        │                 │                 │
        ▼                 ▼                 ▼
    One Pod          One Pod          One Pod

Scheduling

The DaemonSet controller watches nodes.

Whenever a new node appears:

Node Ready
↓
Matches selector
↓
Create Pod
↓
Schedule Pod

Node Selectors

DaemonSets can target only specific nodes.

Example:

spec:
template:
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""

Only worker nodes receive the Pod.


Taints and Tolerations

Control-plane nodes are often tainted.

Example:

master-0
↓
NoSchedule

To run there, the DaemonSet must tolerate the taint.

Example:

tolerations:
- operator: Exists

Without the toleration:

Master Node
×
No Pod

Example DaemonSet

apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-exporter
spec:
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
containers:
- name: node-exporter
image: prom/node-exporter

You don’t specify replicas.

The controller calculates the number automatically.


DaemonSet Lifecycle

Cluster
3 Nodes
↓
DaemonSet
↓
3 Pods

Add two nodes:

Cluster
5 Nodes
↓
DaemonSet
↓
5 Pods

Remove one node:

Cluster
4 Nodes
↓
DaemonSet
↓
4 Pods

Common Use Cases

Monitoring
Node Exporter
↓
Metrics

Logging
Vector
↓
Collect logs

Networking
OVN
↓
Configure networking

Storage

CSI Node Plugin

Every Node
↓
Attach Volumes

Security

Examples:

  • Falco
  • Security agents
  • Endpoint protection
  • File integrity monitoring

DaemonSet vs StatefulSet

DaemonSetStatefulSet
One Pod per nodeStable Pod identity
Node servicesDatabases
Auto-scales with nodesFixed replica count
No persistent identityPersistent identity

DaemonSet vs Deployment

FeatureDeploymentDaemonSet
Replica countYesNo
One Pod per nodeNoYes
Auto-scales with nodesNoYes
Typical useApplicationsPlatform services

Useful Commands

List DaemonSets:

oc get daemonset -A

Describe:

oc describe daemonset node-exporter -n openshift-monitoring

Check Pods:

oc get pods -o wide -n openshift-monitoring

Watch rollout:

oc rollout status daemonset/node-exporter -n openshift-monitoring

Edit:

oc edit daemonset node-exporter -n openshift-monitoring

Note: Do not edit OpenShift-managed DaemonSets (such as node-exporter, machine-config-daemon, or ovnkube-node) directly. They are managed by Operators, and your changes will typically be overwritten. Use the supported Operator configuration instead.


Troubleshooting DaemonSets

Missing Pod on a Node

Check:

oc get daemonset -A

Then:

oc describe daemonset <name>

Verify:

  • Node Selector
  • Taints
  • Tolerations
  • Resource availability
  • Events

Pod Pending

Check:

oc describe pod <pod>

Common causes:

  • No CPU
  • No memory
  • Taint not tolerated
  • Missing image
  • Failed image pull

New Node Has No Pod

Verify:

oc get nodes

Then:

oc get daemonset

Look for:

Desired Number Scheduled
Current Number Scheduled

If they differ:

Desired = 10
Current = 9

Investigate why one node isn’t running the DaemonSet Pod.


Real Production Example

A new worker node joins the cluster.

Within seconds:

New Worker
↓
OVN Pod
↓
Machine Config Daemon
↓
Node Exporter
↓
Vector
↓
CSI Driver

The node becomes fully integrated into the cluster without manual intervention.


Interview Answer (2 Minutes)

A DaemonSet is a Kubernetes workload that ensures one Pod runs on every selected node in the cluster. Unlike a Deployment, where you specify a replica count, a DaemonSet automatically creates a Pod on each matching node and removes it when the node leaves the cluster. In OpenShift, DaemonSets are used for node-level services such as the Machine Config Daemon, OVN-Kubernetes, Node Exporter, Vector log collectors, and CSI storage plugins because these components must run on every node. As the cluster scales, the DaemonSet scales automatically with it. When troubleshooting, I check the DaemonSet status, node selectors, taints and tolerations, events, and whether the number of scheduled Pods matches the number of eligible nodes. One important operational point is that OpenShift-managed DaemonSets are controlled by Operators, so they should be configured through the Operator rather than edited directly.

Leave a Reply