What Are the Key kubectl rollout Commands?
kubectl rollout provides commands to manage Deployment lifecycle: status checks rollout progress, history shows past revisions, undo rolls back to a previous version, pause and resume control rollout progression, and restart triggers a new rollout without changing the spec.
Detailed Answer
The kubectl rollout command group manages the lifecycle of Deployments (and DaemonSets and StatefulSets). These commands are essential for day-to-day operations and are heavily tested in CKA and CKAD exams.
kubectl rollout status
Monitors the progress of a rollout in real-time:
kubectl rollout status deployment/web
# Waiting for deployment "web" rollout to finish: 2 out of 3 new replicas have been updated...
# deployment "web" successfully rolled out
Use the --timeout flag in CI/CD pipelines to fail the pipeline if the rollout takes too long:
kubectl rollout status deployment/web --timeout=120s
# If the rollout does not complete in 120 seconds, the command exits with code 1
The --watch flag (on by default) streams updates. Use --watch=false for a point-in-time check.
kubectl rollout history
Shows the revision history of a Deployment:
kubectl rollout history deployment/web
# REVISION CHANGE-CAUSE
# 1 Initial deployment
# 2 Upgraded to v2.0
# 3 Added resource limits
View details of a specific revision:
kubectl rollout history deployment/web --revision=2
# Pod Template:
# Labels: app=web, pod-template-hash=abc123
# Containers:
# nginx:
# Image: nginx:2.0
The number of revisions stored is controlled by spec.revisionHistoryLimit (default: 10).
kubectl rollout undo
Rolls back to a previous revision:
# Roll back to the immediately previous revision
kubectl rollout undo deployment/web
# Roll back to a specific revision
kubectl rollout undo deployment/web --to-revision=2
This command creates a new rollout that uses the Pod template from the target revision. It is the fastest way to respond to a bad deployment in production.
kubectl rollout pause and resume
Pause a rollout to hold it at its current state:
# Pause the rollout
kubectl rollout pause deployment/web
# Make multiple changes without triggering individual rollouts
kubectl set image deployment/web nginx=nginx:1.28
kubectl set resources deployment/web -c nginx --limits=cpu=500m,memory=512Mi
# Resume to apply all changes as a single rollout
kubectl rollout resume deployment/web
Pausing is useful for:
- Batching changes: Make multiple spec changes and apply them as one rollout
- Manual canary verification: Pause after partial rollout to observe behavior
- Maintenance windows: Prevent rollouts during sensitive periods
kubectl rollout restart
Triggers a rolling restart of all Pods without changing the Deployment spec:
kubectl rollout restart deployment/web
Behind the scenes, this adds a kubectl.kubernetes.io/restartedAt annotation with the current timestamp to the Pod template. Since the template changed, a new rollout begins.
Common use cases:
- Picking up new ConfigMap or Secret values (when not using immutable references)
- Refreshing container images when using
latesttag (not recommended but common) - Recovering from an unknown state
Complete Command Reference
| Command | Purpose | Example |
|---------|---------|---------|
| rollout status | Check rollout progress | kubectl rollout status deploy/web |
| rollout history | View revision history | kubectl rollout history deploy/web |
| rollout undo | Roll back | kubectl rollout undo deploy/web |
| rollout pause | Freeze rollout | kubectl rollout pause deploy/web |
| rollout resume | Continue paused rollout | kubectl rollout resume deploy/web |
| rollout restart | Trigger rolling restart | kubectl rollout restart deploy/web |
Practical Workflow Example
A typical deployment and rollback workflow:
# 1. Deploy a new version
kubectl set image deployment/web nginx=nginx:1.28
# 2. Monitor the rollout
kubectl rollout status deployment/web --timeout=120s
# 3. If something goes wrong, roll back immediately
kubectl rollout undo deployment/web
# 4. Verify the rollback
kubectl rollout status deployment/web
# 5. Check which revision is now active
kubectl rollout history deployment/web
Using rollout in Scripts
#!/bin/bash
# CI/CD deployment script
# Apply the new manifest
kubectl apply -f deployment.yaml
# Wait for rollout to complete
if ! kubectl rollout status deployment/web --timeout=300s; then
echo "Rollout failed — rolling back"
kubectl rollout undo deployment/web
kubectl rollout status deployment/web --timeout=120s
exit 1
fi
echo "Deployment successful"
Supported Resource Types
The kubectl rollout commands work with:
- Deployments — full rollout management
- DaemonSets — rolling update support
- StatefulSets — ordered rolling updates
They do not work with bare Pods, ReplicaSets, or Jobs.
Why Interviewers Ask This
These are everyday operational commands that every Kubernetes practitioner must know. Interviewers expect you to be fluent with rollout management for the CKA and CKAD exams.
Common Follow-Up Questions
Key Takeaways
- kubectl rollout status is the primary command for monitoring rollout progress.
- kubectl rollout undo instantly reverts to the previous revision — essential for incident response.
- kubectl rollout restart is a safe way to restart Pods without changing the Deployment spec.