lifecycle
kubectl rollout
Manages the deployment lifecycle of Deployments, StatefulSets, and DaemonSets. Subcommands cover watching progress, rolling back to a revision, restarting all pods, and pausing/resuming controller reconciliation.
kubectl rollout SUBCOMMAND (status|history|undo|restart|pause|resume) TYPE/NAME [flags] Common flags
| Flag | Purpose |
|---|---|
| --revision | Target revision for history or undo. |
| --to-revision | Revision to roll back to (undo default is previous). |
| --timeout | Max wait for rollout status to succeed. |
| -w, --watch | Watch the rollout status until it completes (default true for status). |
| -n, --namespace | Namespace of the workload. |
Examples
kubectl rollout status deploy/web --timeout=2m Wait for the Deployment to finish rolling out.
kubectl rollout undo deploy/web Roll back to the previous ReplicaSet revision.
kubectl rollout restart deploy/web Trigger a rolling restart (updates pod-template annotation).
kubectl rollout history deploy/web --revision=3 Show the pod template of a specific revision.
Gotcha
restart only works on Deployments/DaemonSets/StatefulSets, not Jobs or bare Pods. undo picks the previous ReplicaSet - if you rolled forward twice, run history first.
Related commands
kubectl scale
Sets a new desired replica count for a Deployment, StatefulSet, ReplicaSet, or ReplicationController. Optional preconditions guard against racing with another controller.
kubectl apply
Declaratively creates or updates resources from a manifest file, directory, URL, or kustomization. Tracks the last-applied configuration so subsequent applies compute a three-way merge patch rather than replacing the object.
kubectl get
Lists one or more resources of a given type from the cluster. It is the primary read command for pods, services, deployments, and any other Kubernetes object, with flexible output formats for scripting and inspection.
kubectl delete
Deletes one or more resources by name, label, or manifest. Supports graceful termination, forced eviction of stuck pods, and cascading deletion of owned objects.
kubectl autoscale
Creates a HorizontalPodAutoscaler (v2) that scales a workload based on CPU utilization. For memory or custom/external metrics, author the HPA manifest directly since this command only exposes CPU targets.