Skip to main content
09

Pod vs Deployment vs StatefulSet vs DaemonSet

EasyKubernetesWorkloads

What's the difference between a Pod, Deployment, StatefulSet, DaemonSet and Job in Kubernetes?

TL;DR

A Pod is the smallest unit: one or more containers that share a network namespace (same IP) and volumes, and are scheduled together. You rarely create Pods directly; controllers manage them. A Deployment runs stateless, interchangeable replicas and handles rolling updates and rollbacks (via ReplicaSets). A StatefulSet gives each replica a stable identity (db-0, db-1), a stable network name, and its own persistent volume, with ordered startup, for databases and clustered systems. A DaemonSet runs one Pod per node, for log collectors, monitoring agents and CNI plugins. A Job runs Pods to completion, and a CronJob runs Jobs on a schedule.

Key points

ControllerPods areTypical use
DeploymentInterchangeableWeb APIs, workers
StatefulSetUnique, ordered, own storagePostgreSQL, Kafka, Elasticsearch
DaemonSetOne per nodeFluent Bit, node-exporter, CNI
Job / CronJobRun to completionMigrations, batch, nightly reports
  • Multiple containers in one Pod: sidecars (proxy, log shipper) and init containers (run before the app, such as waiting for a dependency or running a migration).
  • A StatefulSet needs a headless Service for stable DNS names like db-0.db.namespace.svc.
  • For production databases, a managed service or an operator (CloudNativePG, Strimzi) usually beats a hand-rolled StatefulSet.
  • Deleting a Deployment's Pod gets you a new Pod with a new name and IP; deleting db-0 brings back db-0 with the same volume.

Example

yaml
apiVersion: apps/v1
kind: Deployment
metadata: { name: api }
spec:
  replicas: 3
  selector: { matchLabels: { app: api } }
  template:
    metadata: { labels: { app: api } }
    spec:
      containers:
        - name: api
          image: registry.example.com/api:1.4.2
          ports: [{ containerPort: 8080 }]

Common follow-ups

  • Why not run a bare Pod? Nothing recreates it if it dies or its node fails.
  • What's a ReplicaSet? It keeps N identical Pods running. Deployments manage ReplicaSets to do rolling updates; you don't use them directly.

What interviewers look for

Tip

Match each workload type to a real use case, and explain what StatefulSets add (identity, stable storage, ordering).

  • Red flag: running a database as a Deployment with a shared volume.

Was this helpful?

Related questions