Cybersecurity
Kubernetes
Subjective
Oct 07, 2025
What are DaemonSets and Jobs in Kubernetes, and when would you use each?
Detailed Explanation
DaemonSets and Jobs are specialized workload controllers for specific use cases beyond regular application deployments.\n\nDaemonSets:\nEnsure a copy of a pod runs on all (or selected) nodes\n• Automatically schedules pods on new nodes\n• Removes pods when nodes are removed\n• Typically used for system-level services\n• Ignores unschedulable nodes by default\n\nDaemonSet Use Cases:\n• Log collection agents (Fluentd, Filebeat)\n• Monitoring agents (Node Exporter, Datadog)\n• Network plugins (Calico, Weave)\n• Storage daemons (Ceph, GlusterFS)\n• Security agents\n\nJobs:\nRun pods to completion for batch processing\n• Ensures specified number of successful completions\n• Handles pod failures and retries\n• Supports parallel execution\n• Cleans up completed pods\n\nJob Types:\n• Job: Run once to completion\n• CronJob: Scheduled recurring jobs\n• Parallel Jobs: Multiple pods running simultaneously\n\nExample DaemonSet:\napiVersion: apps/v1\nkind: DaemonSet\nmetadata:\n name: log-collector\nspec:\n selector:\n matchLabels:\n app: log-collector\n template:\n metadata:\n labels:\n app: log-collector\n spec:\n containers:\n - name: fluentd\n image: fluentd:latest\n volumeMounts:\n - name: varlog\n mountPath: /var/log\n volumes:\n - name: varlog\n hostPath:\n path: /var/log\n\nBest Practices:\n• Use node selectors for targeted deployment\n• Set resource limits for DaemonSet pods\n• Implement proper job cleanup policies\n• Monitor job completion and failure rates\n• Use init containers for setup tasks
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts