Kubernetes Tutorial — Part 3: Deployments, ReplicaSets, and Self-Healing

By Suraj Ahir March 09, 2026 8 min read

← Part 2 Kubernetes Tutorial · Part 3 of 12 Part 4 →
Kubernetes - Deployments
Kubernetes - Deployments

Running a single pod directly is fine for testing, but in production you never do that. If a pod crashes, it stays dead. Deployments solve this by maintaining the desired number of running pods automatically.

Creating a Deployment

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: nginx:1.25
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
Apply and Scale
kubectl apply -f deployment.yaml
kubectl get deployments
kubectl scale deployment web-app --replicas=5

# Watch self-healing
kubectl delete pod web-app-xyz  # Replacement appears automatically
kubectl get pods -w

Rolling Updates

Update and Rollback
kubectl set image deployment/web-app web=nginx:1.26
kubectl rollout status deployment/web-app
kubectl rollout undo deployment/web-app  # If something goes wrong

In Part 4, we will learn about Services — how to expose your Deployments so they can receive traffic.

← Part 2 Kubernetes Tutorial · Part 3 of 12 Part 4 →
← Back to Blog
Disclaimer: This content is for educational purposes only. SRJahir Tech does not guarantee any specific outcome, job placement, or exam result. Learning requires consistent effort and practical application.