TIL: scale down a Kubernetes DaemonSet

β€”

by

in ,

A DaemonSet is supposed to run on all or some Kubernetes nodes, so scaling it down is surprisingly easy: Set a nodeSelector to some label which doesn’t exist, and the DaemonSet is scaled to 0.

kubectl patch daemonset the-ds -p '{"spec": {"template": {"spec": {"nodeSelector": {"doesnt-exist": "true"}}}}}'

This will patch (-p) the DaemonSet and add a nodeSelector ( spec.template.spec.nodeSelector) which makes the DaemonSet run on all nodes which are labeled “doesnt-exist: true“.

Since there are no nodes with this label, the DaemonSet is scaled to 0.


Comments

Leave a Reply