Deployment
In one line
A Deployment is a Kubernetes resource that manages a set of Pods, enabling scaling, updates, and rollbacks.
In simple words
A Deployment is one of the most important Kubernetes resources. It manages a set of identical Pods and provides features like scaling, rolling updates, and rollbacks.
Instead of creating Pods directly (which are ephemeral and hard to manage), you create a Deployment. You tell it "I want 3 replicas of my app" and the Deployment creates 3 Pods. If one Pod dies, the Deployment automatically creates a new one.
When you update your application (e.g., new image version), the Deployment performs a rolling update — it gradually replaces old Pods with new ones, so there is no downtime. If something goes wrong, you can roll back to the previous version with a single command.
Example
# Update the image and Kubernetes rolls out gradually
kubectl set image deployment/my-app my-app=my-app:v2
# Roll back if something goes wrong
kubectl rollout undo deployment/my-appThe first command updates the container image; Kubernetes performs a rolling update. The second command rolls back to the previous version.
How it works
- You define a Deployment with a desired number of replicas.
- The Deployment controller creates Pods to match the desired count.
- When you update the image, it creates new Pods and gradually removes old ones.
- You can roll back to a previous revision if the new version has issues.
Common confusions
Confused with: Pod
The difference: A Pod is a single instance; a Deployment manages multiple Pods and provides scaling, updates, and self-healing.
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.