201 β€” Deployments and ReplicaSets

Intermediate

Master Deployments to manage application replicas, perform rolling updates, and ensure high availability in Kubernetes.

Learning Objectives

1
Create and manage Deployments
2
Understand ReplicaSets and their relationship to Deployments
3
Scale applications horizontally
4
Perform rolling updates and rollbacks
Step 1

Create your first Deployment

Deploy a replicated application using a Deployment resource.

Commands to Run

kubectl create deployment nginx-deploy --image=nginx:alpine --replicas=3
kubectl get deployments
kubectl get replicasets
kubectl get pods

What This Does

Deployments manage ReplicaSets, which manage Pods. This creates 3 identical nginx pod replicas for high availability.

Expected Outcome

1 Deployment created, 1 ReplicaSet created, 3 Pods running. All with auto-generated names.

Pro Tips

  • 1
    Deployments > ReplicaSets > Pods (ownership hierarchy)
  • 2
    Never manage Pods directly in production - use Deployments
  • 3
    ReplicaSets ensure desired number of pods are always running
  • 4
    If a pod dies, ReplicaSet creates a replacement
  • 5
    Deployment names must be unique per namespace

Common Mistakes to Avoid

  • ⚠️Creating pods directly instead of using Deployments
  • ⚠️Not understanding the three-layer hierarchy
Was this step helpful?

All Steps (0 / 10 completed)