source : Medium

🔁 ReplicaSet

A ReplicaSet (RS) ensures that a specified number of replica Pods are running at any given time. If a Pod goes down, the RS automatically creates a new one.

🔧 Example YAML:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: my-replicaset
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: nginx
          image: nginx:latest

✅ Responsibilities:

  • Maintains desired pod count
  • Replaces failed or deleted pods
  • BUT: No built-in support for rolling updates

🚀 Deployment

A Deployment is a higher-level abstraction over ReplicaSet. It manages ReplicaSets and provides features like:

  • Rolling updates
  • Rollbacks
  • Scaling
  • Strategy-based updates

🤣 Rolling updates?

Rolling updates in Kubernetes let you update your application gradually, with zero downtime.

 

Instead of stopping all old Pods and starting all new ones at once (which can cause downtime), Kubernetes replaces Pods one at a time (or a few at a time), so the application keeps running smoothly.

🔧 Example YAML:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: nginx
          image: nginx:latest

💡 Notice it looks very similar to a ReplicaSet — but you get more features.


⚖️ Difference Summary

FeatureReplicaSetDeployment
Manages Pods ✅ Yes ✅ Yes
Rolling Updates ❌ No ✅ Yes
Rollbacks ❌ No ✅ Yes
Used Directly? ⚠️ Rarely ✅ Common
Underlying Object Yes (used by Deployments) Yes (wraps RS)

Powered by. ChatGPT

'CS > Kubernetes' 카테고리의 다른 글

[Kubernetes] Scheduling(2)  (0) 2025.04.04
[Kubernetes] Scheduling(1)  (0) 2025.04.04
[Kubernetes] Service  (1) 2025.03.28
[Kubernetes] YAML  (1) 2025.03.27
[Kubernetes] Kubernetes concepts  (1) 2025.03.27