Deployments: Declarative Updates
What you'll learn: How Deployments manage application updates, rollbacks, and versioning through declarative configuration.
The Core Idea
A Deployment in Kubernetes wraps ReplicaSets with powerful declarative update capabilities. Instead of manually creating and managing ReplicaSets, you describe your desired state in a Deployment manifest, and Kubernetes handles the transition from the current state to your new version—including rolling updates, rollback capabilities, and revision history.
Think of it like editing a blueprint rather than reconstructing a building by hand. You update the blueprint (your Deployment YAML), and Kubernetes automatically orchestrates the construction work.
How Deployments Work
When you update a Deployment (say, changing the container image tag from v1.0 to v2.0), Kubernetes:
- Creates a new ReplicaSet for the updated Pod template
- Gradually scales up the new ReplicaSet while scaling down the old one
- Ensures zero or minimal downtime through rolling updates
- Maintains revision history for rollbacks
This process is declarative—you specify the end goal, not the steps to get there.
Rolling Updates and Rollbacks
Deployments control update speed through parameters like maxUnavailable (how many Pods can be down during updates) and maxSurge (how many extra Pods can exist temporarily). If something goes wrong, you can instantly roll back to a previous revision using the stored history.
You can also pause a rollout midway, verify the new version with a canary subset of traffic, then continue—all through simple kubectl commands against your declarative configuration.
Versioning and History
Kubernetes maintains a revision history of your Deployments. Each change creates a new ReplicaSet (the old ones scale to zero but remain for rollback). This versioned approach lets you track what changed, when, and quickly revert if needed.
Key Takeaway: Deployments provide declarative, versioned updates with built-in rolling update strategies and instant rollback capabilities, abstracting away the manual orchestration of ReplicaSets.