Kubernetes DaemonSets Simplified: Run on Every Node

Listen to this Post

Kubernetes DaemonSets ensure that a specific pod runs on every node (or selected nodes) in the cluster. They are ideal for deploying node-level agents like log collectors, monitoring agents, or network plugins.

Read the full article here: Kubernetes DaemonSets – Run on Every Node

You Should Know:

1. Creating a DaemonSet

A basic DaemonSet YAML configuration:

apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-logging
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-logging
template:
metadata:
labels:
name: fluentd-logging
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd
image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log

2. Verifying DaemonSet Deployment

Check DaemonSet status:

kubectl get daemonset -n kube-system

View pods running on each node:

kubectl get pods -n kube-system -o wide

3. Updating a DaemonSet

Rolling update for a DaemonSet:

kubectl rollout restart daemonset <daemonset-name> -n <namespace>

4. Deleting a DaemonSet

Remove a DaemonSet:

kubectl delete daemonset <daemonset-name> -n <namespace>

5. Node Selectors & Taints/Tolerations

To restrict DaemonSets to specific nodes:

nodeSelector:
disktype: ssd

For tainted nodes (e.g., master nodes):

tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"

6. Monitoring DaemonSets

Check DaemonSet events:

kubectl describe daemonset <daemonset-name> -n <namespace>

What Undercode Say:

DaemonSets are crucial for cluster-level operations, ensuring essential services like logging (fluentd), monitoring (Prometheus Node Exporter), or networking (Calico) run on every node. Use `kubectl` commands to manage them efficiently, and leverage `nodeSelector` and `tolerations` for granular control. Always verify deployments and monitor resource usage to avoid node congestion.

Expected Output:

$ kubectl get daemonset -n kube-system 
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE 
fluentd-logging 3 3 3 3 3 <none> 2d 

For further reading:

References:

Reported By: Sandip Das – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image