How to scale a Kubernetes DaemonSet to 0
Codemia Knowledge Hub ·
A DaemonSet has no replica count, so you cannot scale it the way you scale a Deployment. Its whole purpose is to run a pod on every matching node. To get it to zero pods without deleting it, change where its pods are allowed to schedule: taint the nodes and make sure the DaemonSet has no toleration for that taint.
A DaemonSet is a controller that ensures a specific pod runs on all or some nodes in a cluster. When a node joins, Kubernetes schedules the pod on it automatically. Typical uses are logging daemons, monitoring agents, and per-node network services such as proxies or firewalls.
Why take a DaemonSet to zero
You may need to stop the workload on every node while keeping the DaemonSet configuration:
- Reducing resource usage during low traffic periods.
- Debugging, testing, or redeploying updated DaemonSet configurations.
- Preventing interference during critical operations or upgrades.
Steps with taints and tolerations
- Taint all nodes. A taint lets a node repel pods that do not have a matching toleration.
This taints every node with key=value and the NoSchedule effect, so no new pod without the matching toleration can be scheduled there.
- The toleration that matches the taint. A DaemonSet with this toleration can still schedule onto the tainted nodes, so this is the spec to remove (or keep, when you restore):
- Remove the toleration. Without a toleration for the taint, the DaemonSet's pods are no longer scheduled, and the DaemonSet is effectively at 0.
- Verify that no pods from the DaemonSet are running:
If no pods belong to the DaemonSet, it is at 0.
Restoring the DaemonSet
When you want the pods back, remove the taint from the nodes and revert any changes you made to the DaemonSet spec:
Side effects to watch for
- Other workloads: a
NoScheduletaint on every node also blocks scheduling of other workloads that lack the toleration, which can affect the cluster if not handled. - Version compatibility: taints and tolerations have been available since Kubernetes 1.6.
- Automation: script the tainting and toleration changes so they are applied and reverted consistently.
Quick reference
| Topic | Details |
| Objective | Scale DaemonSet to 0 at will |
| Method | Use taints and tolerations |
| Commands Involved | kubectl taint, kubectl get pods |
| Impact | Removes scheduling of pods while maintaining DaemonSet config |
| Restoration | Remove taints to resume normal operation |
| Version Requisite | Kubernetes 1.6+ |
| Automation Potential | High, scriptable task |
Related reading
- How to schedule pods restart
- How to scrape metrics-server to prometheus outside kubernetes cluster
- How to see logs of terminated pods
- How to see Pod logs a container name must be specified for pod... choose one of wait main
- How to scan between date range using Lambda and DynamoDB?
- How to schedule tasks on SageMaker
- How to search for plain text in cloudwatch logs insights?
- How to see all running Amazon EC2 instances across all regions?
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.