Course contentsShow
← Cloud and Infrastructure
Lesson 1170 of 2,98923. Kubernetes WorkloadsFree lesson

Rollback and Revision History

Roll back to previous Deployment revisions using kubectl rollout undo and manage revision history limits.

Rollback and Revision History

What you'll learn: How to safely undo Deployment changes and manage the history of your rollouts.

Every time you update a Deployment (changing an image, labels, or pod template), Kubernetes creates a new revision—a snapshot of that version. This history acts like an undo stack, letting you revert to previous working configurations when something goes wrong.

How Rollback Works

When a new rollout causes problems (crashes, errors, performance issues), you can instantly roll back using:

kubectl rollout undo deployment/my-deployment

This command reverts to the previous revision by default. Think of it like hitting "Undo" in a text editor—Kubernetes restores the prior configuration and performs a rolling update backward.

Rolling Back to a Specific Revision

You can view your Deployment's history:

kubectl rollout history deployment/my-deployment

To jump back to a specific revision (say, revision 3):

kubectl rollout undo deployment/my-deployment --to-revision=3

Managing Revision History Limits

Kubernetes doesn't keep every revision forever. The revisionHistoryLimit field (default: 10) controls how many old ReplicaSets are retained. In your Deployment spec:

spec:
  revisionHistoryLimit: 5

Setting this too low means fewer rollback options; too high consumes more cluster resources storing old ReplicaSets.

Analogy

Imagine revisions as checkpoints in a video game. Each major change creates a save point you can return to if things go wrong. revisionHistoryLimit determines how many save slots you keep—balance safety with storage space.

Key Takeaway: Use kubectl rollout undo to instantly revert failed Deployments, view history with rollout history, and control storage with revisionHistoryLimit to balance recovery options against cluster overhead.