Skip to content

Deployment vs ReplicaSet vs Pod

Mental model

Layer cake: Deployment -> ReplicaSet -> Pod. Each layer has exactly one job.

What it looks like

Three objects for "run my app" feels over-engineered.

What it really is

Pod: runs containers. No self-healing. If it dies, it stays dead. Nobody recreates it.

ReplicaSet: ensures N copies of a pod template are running at all times. If a pod dies, the ReplicaSet creates a replacement.

Deployment: manages ReplicaSets. Handles rolling updates and rollbacks by creating new ReplicaSets and scaling old ones down.

Why it seems confusing

Three layers feels like too much abstraction. But each layer does one thing: - Pod = actual execution. - ReplicaSet = replica count enforcement. - Deployment = desired state declaration + update strategy.

What actually matters

  • You almost never create ReplicaSets directly. You create Deployments.
  • Rolling update: Deployment creates a new ReplicaSet, scales it up, scales the old ReplicaSet down.
  • Rollback: Deployment points back to a previous ReplicaSet.
  • The ownership chain is visible: Deployment owns ReplicaSet, ReplicaSet owns Pods.
flowchart TD
    D["Deployment\n(update strategy + desired state)"]
    D --> RS1["ReplicaSet v1\n(replica count: 0)"]
    D --> RS2["ReplicaSet v2\n(replica count: 3)"]
    RS2 --> P1["Pod"]
    RS2 --> P2["Pod"]
    RS2 --> P3["Pod"]

    style D fill:#36f,color:#fff
    style RS2 fill:#f80,color:#fff
    style RS1 fill:#888,color:#fff

Common mistakes

  • Creating bare pods without a Deployment. They will not be replaced if they die.
  • Manually editing ReplicaSets that are owned by a Deployment. The Deployment will overwrite your changes.
  • Confusing "replicas: 0" (scaled down, still exists) with deleting the Deployment.

Small examples

# See the ownership chain
kubectl get deploy,rs,pod -l app=web

# Output shows:
# deployment.apps/web    3/3
# replicaset.apps/web-7d9f8b6   3
# pod/web-7d9f8b6-abc   Running
# pod/web-7d9f8b6-def   Running
# pod/web-7d9f8b6-ghi   Running

# Watch a rolling update
kubectl set image deployment/web app=myapp:2.0
kubectl rollout status deployment/web

One-line summary

Deployment manages ReplicaSets which manage Pods: three layers separating update strategy, replica count, and execution.