CKAD field manual
k8s DaemonSet YAML example
A DaemonSet puts one Pod on every matching node. New node → new Pod. Gone node → Pod gone.
kubectl create deploy agent --image=nginx:1.27 -o yaml --dry-run=client > ds.yaml
# kind: DaemonSet — delete replicas and strategy
kubectl apply -f ds.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: agent
namespace: default
spec:
selector:
matchLabels:
app: agent
template:
metadata:
labels:
app: agent
spec:
containers:
- name: nginx
image: nginx:1.27
spec:
template:
spec:
nodeSelector:
disk: ssd
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
containers:
- name: shipper
image: busybox:1.36
command: ["sleep", "1d"]
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
hostPath:
path: /var/log
kubectl set image ds/agent nginx=nginx:1.28
kubectl rollout status ds/agent
kubectl rollout history ds/agent
kubectl rollout undo ds/agent
kubectl get ds,po -l app=agent -o wide
kubectl drain node-1 --ignore-daemonsets --delete-emptydir-data
Fields
- selector
- Must match template.metadata.labels. Immutable after create.
- template
- The Pod. There is no replicas field — one per matching node.
- nodeSelector
- Only matching nodes get a Pod. Omit it for every Ready node.
- tolerations
- Tainted nodes (control-plane) stay empty without these.
- updateStrategy
- RollingUpdate is the default. OnDelete waits until you delete each Pod.
- hostPath
- The node filesystem. Typical for log agents. Path is on the node, not in the image.
- replicas
- Not a DaemonSet field. Delete it if you dry-run a Deployment.
- kubectl create deploy
- No DaemonSet generator. Dry-run a Deployment, then kind: DaemonSet and drop replicas.
- kubectl rollout
- Works on a DaemonSet the same as a Deployment.
Watch
- No replicas field. One Pod per matching node. A new node gets a Pod; a gone node loses it.
- selector.matchLabels and template.metadata.labels must match. The selector is immutable after create.
- There is no kubectl create daemonset. Dry-run a Deployment, set kind: DaemonSet, delete replicas and strategy.
Official docs DaemonSets