Kubernetes has become the standard for deploying containerized applications at scale. But deploying your app is more than just launching a few pods—how you roll out updates can make or break your service’s reliability.
In this article, you'll learn:
- What deployment strategies are in Kubernetes
- The pros and cons of Recreate vs Rolling Update
- How to configure deployments for stability
- How to manage rollouts and perform rollbacks
- Real-world tips for production-grade releases
Let’s dive in.
📆 What Is a Kubernetes Deployment?
A Deployment in Kubernetes is a controller that manages the lifecycle of pods. It ensures your app runs consistently by automatically creating, updating, or replacing pods when you make changes.
For example, you might define a deployment to run 5 replicas of your web app. Kubernetes will:
- Ensure there are always 5 running
- Replace any failed pods automatically
- Update all replicas when the container image is changed
Think of it as an intelligent “app manager” that tracks versions and guarantees availability.
🛍️ Deployment Strategy: Why It Matters
When you update an application in Kubernetes, the deployment strategy determines how new versions are rolled out and what happens to the existing pods. The wrong strategy could cause:
- Downtime
- Partial outages
- Broken user experiences
🔄 Two Primary Strategies in Kubernetes
1. ❌ Recreate Strategy
This method stops all existing pods before starting new ones.
🔧 Use case:
- Applications that can tolerate downtime
- Workloads that must be restarted cleanly
✅ Pros:
- Simple and predictable
- Useful for legacy or stateful apps
❌ Cons:
- Causes complete downtime during updates
🔍 Example YAML:
strategy:
type: Recreate
2. ✅ Rolling Update Strategy (default)
This method gradually replaces old pods with new ones—ideal for modern cloud-native apps.
🔧 Use case:
- Web services or microservices
- CI/CD pipelines aiming for zero downtime
✅ Pros:
- No service interruption
- Safer and more user-friendly
❌ Cons:
- Slightly more complex configuration
- Requires monitoring during rollout
🔍 Example YAML:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
⚙️ Configuring Rolling Updates in Practice
These two parameters are critical to managing risk:
-
maxSurge
: the maximum number of extra pods that can be created during the update -
maxUnavailable
: the number of pods that can be offline at the same time
🔍 Full Deployment Example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: my-app:2.0
🧚 Monitoring & Rollback: Stay in Control
Even the best strategies can go wrong. Kubernetes provides built-in tools to monitor and fix rollouts in real time.
✅ Check Deployment Status
kubectl rollout status deployment/my-app
📜 View Revision History
kubectl rollout history deployment/my-app
🔁 Roll Back to a Previous Version
kubectl rollout undo deployment/my-app
You can also target a specific revision:
kubectl rollout undo deployment/my-app --to-revision=2
📘 Best Practices for Kubernetes Rollouts
1. Test in a Staging Environment
Never ship directly to production. Validate changes in a near-identical staging cluster.
2. Annotate Your Changes
Track deployment history and root causes:
kubectl annotate deployment my-app kubernetes.io/change-cause="Upgrade to v2.0"
3. Set a Progress Deadline
This prevents rollouts from getting stuck forever:
progressDeadlineSeconds: 600
4. Use CI/CD Pipelines
Automate your rollouts with GitOps, ArgoCD, or Flux for faster, safer releases.
💡 Bonus Tips
- Combine Rolling Updates with health checks (liveness/readiness probes) to ensure only healthy pods serve traffic.
- Use Prometheus + Grafana or Datadog to monitor latency, errors, and availability during rollouts.
🧠 FAQ
What is the difference between Recreate and Rolling Update?
Recreate stops everything before updating. Rolling Update replaces pods incrementally, keeping the service available.
How can I check if a deployment was successful?
Use kubectl rollout status
to track progress and confirm success.
Can I undo a failed deployment?
Yes! Use kubectl rollout undo
to revert to the last known good version.
Is Rolling Update safe for all workloads?
It’s ideal for stateless services. For stateful apps, consider using StatefulSets and PodDisruptionBudgets.
🏁 Conclusion
Choosing the right deployment strategy in Kubernetes is key to building reliable and scalable systems. Whether you opt for a simple Recreate or a production-grade Rolling Update, your approach will directly affect user experience and operational risk.
By mastering these tools and patterns, you’ll deploy faster, recover smarter, and scale with confidence.