DaemonSets & CronJobs

Manage specialized workloads like node monitoring agents (DaemonSets), batch execution tasks (Jobs), and scheduled tasks (CronJobs).

1. Workload Types Comparison

KindExecution PatternPrimary Use Case
DaemonSetEnsures ALL (or selected) Worker Nodes run exactly 1 copy of the PodLog collectors (Fluentd/Logstash), Monitoring agents (Prometheus Node Exporter), Network CNI plugins
JobRuns Pods to completion once and exits with success statusDatabase migrations, batch data processing, backup generation
CronJobRuns Jobs on a recurring schedule using standard 5-field cron syntaxNightly backups, cleanup scripts, automated daily reporting

2. Production CronJob Manifest Example

apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-db-backup
spec:
  schedule: "0 2 * * *" # Runs every night at 2:00 AM UTC
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: backup-script
              image: postgres:15-alpine
              command: ["/bin/sh", "-c", "pg_dumpall > /backups/db.sql"]
          restartPolicy: OnFailure

Next Up

Learn Namespaces & Multi-Tenancy: default vs custom namespaces (dev, prod), ResourceQuotas, and LimitRanges.

Next Lesson: Namespaces & Quotas →