Skip to main content
In this tutorial, you will learn how to manage rolling updates and rollbacks for Kubernetes Deployments. We’ll cover:
  1. Creating a Deployment
  2. Downgrading an image using kubectl edit
  3. Updating the image with kubectl set image
  4. Rolling back to a previous revision
  5. Simulating and recovering from a failed rollout

1. Create the Deployment

First, ensure there are no existing Pods in the default namespace:
Define your Deployment in deployment.yaml:
Create the Deployment and track its rollout:
View the rollout history:

2. Downgrade NGINX via kubectl edit

Inspect the current spec:
All Pods run nginx:latest by default. To downgrade to nginx:1.18:
Locate the container definition and update the image tag:
Browse all available NGINX tags on Docker Hub to pick a stable version:
https://hub.docker.com/_/nginx
The image shows a quick reference guide for NGINX Docker maintainers, listing supported tags and respective Dockerfile links.
Save and close the editor, then monitor the rollout:
Verify the annotation:
Look under Annotations for:
kubernetes.io/change-cause=kubectl edit deployment myapp-deployment --record

3. Update Using kubectl set image

Alternatively, patch the image without editing YAML:
Confirm all Pods have the updated image:

4. Roll Back to a Previous Revision

If nginx:1.18-perl proves unstable, revert to revision 2 (the plain 1.18):

5. Simulate a Failed Rollout

Intentionally introduce a bad image to see rollback behavior:
Change the image to an invalid tag:
Using a non-existent image will trigger ImagePullBackOff errors and stall the rollout.
Ensure you revert quickly to avoid service disruption.
Save and watch the rollout status:
Inspect Pods:
Rollback the faulty revision:
All Pods should now run nginx:1.18 again.

Watch Video