πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Deployments beginner ⏱ 15 minutes K8s 1.28+

Kubernetes Deployment Complete Guide

Create and manage Kubernetes Deployments for stateless applications. Covers replicas, selectors, rolling updates, rollback, and deployment strategies.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Create and manage Kubernetes Deployments for stateless applications. Covers replicas, selectors, rolling updates, rollback, and deployment strategies.

The Problem

This is one of the most searched Kubernetes topics. A comprehensive, well-structured guide helps engineers of all levels quickly find actionable solutions.

The Solution

Detailed implementation with production-ready examples below.

Create a Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0      # Zero-downtime
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: nginx:1.25
          ports:
            - containerPort: 80
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              memory: 256Mi
          readinessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 5
          livenessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 15

Manage Deployments

# Create
kubectl apply -f deployment.yaml

# Scale
kubectl scale deployment web-app --replicas=5

# Update image
kubectl set image deployment/web-app web=nginx:1.26

# Check rollout
kubectl rollout status deployment/web-app
kubectl rollout history deployment/web-app

# Rollback
kubectl rollout undo deployment/web-app

# Restart (rolling)
kubectl rollout restart deployment/web-app

# Pause/resume
kubectl rollout pause deployment/web-app
kubectl rollout resume deployment/web-app

# Delete
kubectl delete deployment web-app

Deployment Strategies

StrategymaxSurgemaxUnavailableBehavior
Safe (zero-downtime)10One new before removing old
Fast25%25%Replace 25% at a time
RecreateN/AN/AKill all old, start all new
graph LR
    A[Deployment] -->|manages| B[ReplicaSet v1]
    A -->|creates on update| C[ReplicaSet v2]
    B --> D[Pod v1-a]
    B --> E[Pod v1-b]
    C --> F[Pod v2-a]
    C --> G[Pod v2-b]

Frequently Asked Questions

Deployment vs Pod?

Never create bare Pods in production. Deployments manage ReplicaSets which manage Pods β€” giving you replicas, rolling updates, rollback, and self-healing.

How many revisions are kept?

Default revisionHistoryLimit: 10. Old ReplicaSets (scaled to 0) are kept for rollback. Set to 0 to save etcd space if you don’t need rollback.

Common Issues

Check kubectl describe and kubectl get events first β€” most issues have clear error messages pointing to the root cause.

Best Practices

  • Follow least privilege β€” only grant the access that’s needed
  • Test in staging before applying to production
  • Monitor and alert on key metrics
  • Document your runbooks for the team

Key Takeaways

  • Essential knowledge for Kubernetes operations
  • Start simple and evolve your approach
  • Automation reduces human error
  • Share knowledge with your team
#deployment #replicas #rolling-update #rollback #kubernetes
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens