Build a Node-Level Log Collector DaemonSet
Ops needs a log shipper running on every node — exactly one pod per node, now and on any node added later. Build a DaemonSet that satisfies this and confirm it lands a Ready pod on each node.
The situation
There's no per-node log collection. You need an agent that runs one pod on every node in the cluster — and automatically on any node that joins later. That workload shape is a DaemonSet, not a Deployment.
┌─────────┐
┌─────1 pod────▶│worker-1 │
┌──────────────────────┐──┘ │ │
│DaemonSet node-logger │ └─────────┘
│ │──┐ ┌─────────┐
└──────────────────────┘ └─────1 pod────▶│worker-2 │
│ │
└─────────┘
Your task
In the kubelings namespace, create a DaemonSet named node-logger:
- One pod per node (DaemonSets do this by design — no
replicas). - Use image
ghcr.io/iximiuz/labs/busybox:latest, command e.g.sh -c 'while true; do echo collecting; sleep 3600; done'. - All its pods must reach Ready.
kubectl -n kubelings get ds,pods -o wide
Hint
kubectl -n kubelings create -f - <<'EOF'
apiVersion: apps/v1
kind: DaemonSet
metadata: {name: node-logger}
spec:
selector: {matchLabels: {app: node-logger}}
template:
metadata: {labels: {app: node-logger}}
spec:
containers:
- name: agent
image: ghcr.io/iximiuz/labs/busybox:latest
command: ["sh","-c","while true; do echo collecting; sleep 3600; done"]
EOF
Control-plane nodes are schedulable in this playground, so no tolerations are strictly required — but adding a control-plane toleration is good practice.
Solution
Approach
A per-node agent is a DaemonSet — it schedules exactly one pod per eligible node and tracks node add/remove automatically.
Create it
kubectl -n kubelings apply -f - <<'EOF'
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-logger
spec:
selector:
matchLabels: {app: node-logger}
template:
metadata:
labels: {app: node-logger}
spec:
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
containers:
- name: agent
image: ghcr.io/iximiuz/labs/busybox:latest
command: ["sh","-c","while true; do echo collecting; sleep 3600; done"]
EOF
Verify
kubectl -n kubelings get ds node-logger
kubectl -n kubelings get pods -l app=node-logger -o wide
DESIRED should equal READY and match the node count.
- Previous lesson
- Fix the Rolling Update: unsafe maxSurge/maxUnavailable