DeamonSet¶
- A
DaemonSet
ensures that all (or some) Nodes run a copy of a Pod. - As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected.
- Deleting a
DaemonSet
will clean up the Pods it created.
Typical uses of a DaemonSet
- Running a cluster storage daemon on every node
- Log collection: Running a logs collection daemon on every node
- Monitoring: Running a node monitoring daemon on every node
Commands¶
k get ds
We can not create ds using the kubectl, so we can
The fastest way to create is to create a deployment
kubectl create deploy nginx --image=nginx --dry-run -o yaml > nginx-ds.yaml
Now replace the line kind: Deployment with kind: DaemonSet in nginx-ds.yaml
and remove the line replicas: 1
, strategy {}
and status {}
as well. Otherwise, it shows error for some required fields like this
error: error validating "nginx-ds.yaml": error validating data: [ValidationError(DaemonSet.spec): unknown field "strategy" in io.k8s.api.apps.v1.DaemonSetSpec, ValidationError(DaemonSet.status): missing required field "currentNumberScheduled" in io.k8s.api.apps.v1.DaemonSetStatus,ValidationError(DaemonSet.status): missing required field "numberMisscheduled" in io.k8s.api.apps.v1.DaemonSetStatus, ValidationError(DaemonSet.status): missing required field "desiredNumberScheduled" in io.k8s.api.apps.v1.DaemonSetStatus, ValidationError(DaemonSet.status): missing required field "numberReady" in io.k8s.api.apps.v1.DaemonSetStatus]; if you choose to ignore these errors, turn validation off with --validate=false