Hello! Today, I’m going to give you a complete overview of the 4 major Pod Controllers, which are key to Kubernetes workload management.
Beyond simply launching Pods, choosing the optimal tool for each situation is the starting point for cloud security and infrastructure design. In about 15 minutes, you can master all the essentials needed for practical work and the CKAD exam.

📑 Table of Contents
- Overview: Why use controllers? (Desired State)
- Deployment: The king of Stateless applications
- StatefulSet: The manager for experts with State (Stateful)
- DaemonSet: The guardian watching over all nodes
- Job & CronJob: Masters of batch processing that work short and intensely
- [Appendix] Controller selection guide and practical tips
0. Overview: Why use controllers? 🤔
In Kubernetes, Pods are consumables that can die at any time. As the instructor emphasizes, we do not manually manage Pods one by one. Instead, we declare our “Desired State” to the controller, and the controller monitors the current state and maintains that state.
1. Deployment: The king of Stateless applications 👑
This is the most commonly used controller. It is optimized for stateless applications, such as web servers or API servers, where Pods do not need to be distinguished from each other.
- Key Features: Self-healing, scaling, rolling updates, and rollbacks.
- Core Resource: Internally creates a ReplicaSet to maintain the number of Pods.
💡 Practical Code (YAML)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.21
2. StatefulSet: The manager for experts with State (Stateful) 🏛️
Used when Pods require unique names and persistent data, such as databases (MySQL, MongoDB) or message queues (Kafka).
- Key Features: Assigns sequential indexes to Pods (pod-0, pod-1), stable network identifiers (Headless Service integration), individual volume allocation (volumeClaimTemplates).
- Difference: Unlike Deployment, the name and associated volume are retained even if the Pod restarts.
3. DaemonSet: The guardian watching over all nodes 🛡️
Used when you need to run exactly one Pod on every node (or nodes meeting specific conditions) within the cluster.
- Usage: Log collectors (Fluentd), monitoring agents (Prometheus Node Exporter), network plugins.
- Characteristics: When a new node is added, a Pod is automatically deployed, and when a node is deleted, the Pod is also removed.
4. Job & CronJob: Masters of batch processing 🏃♂️⏰
Manages tasks that terminate themselves after a specific job is completed, rather than services that run 24/7.
- Job: One-time tasks (e.g., data migration, batch report generation). Terminates the Pod upon successful completion.
- CronJob: Tasks that run repeatedly at scheduled times (e.g., etcd backup every day at 3 AM).
💡 Practical Code (CronJob)
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-backup
spec:
schedule: "0 3 * * *" # Every day at 3 AM
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: busybox
command: ["sh", "-c", "echo Backup Complete!"]
restartPolicy: OnFailure
📊 Controller Comparison at a Glance
| Controller | Primary Use Case | Pod Identifier | Data Persistence |
| — | — | — | — |
| Deployment | Web servers, APIs (Stateless) | Random hash | Volatile |
| StatefulSet | DBs, Distributed systems (Stateful) | Unique index (0, 1, 2) | Persistent (PVC mapping) |
| DaemonSet | Log/Monitoring agents | Node-specific fixed | Node-dependent |
| Job/CronJob | Backup, Batch processing | One-time/Repeated | Results saved, then terminates |
—
Tags: Kubernetes, CKAD, Deployment, StatefulSet, DaemonSet, Job, CronJob, Cloud Infrastructure, Certification Prep, Pod Controller
Leave a Reply