LinuxCommandLibrary

kubectl-rollout

Manage Kubernetes rollout deployments

TLDR

Start a rolling restart of a resource

$ kubectl rollout restart [resource_type]/[resource_name]
copy

Watch the rolling update status of a resource
$ kubectl rollout status [resource_type]/[resource_name]
copy

Roll back a resource to the previous revision
$ kubectl rollout undo [resource_type]/[resource_name]
copy

View the rollout history of a resource
$ kubectl rollout history [resource_type]/[resource_name]
copy

SYNOPSIS

kubectl rollout [<COMMAND>] [<NAME>] [--revision=<int>] [--to-revision=<int>] [-h|--help]

PARAMETERS

-h, --help
    Display help for rollout

--revision int
    Revision to rollback to (defaults to 0, latest)

--to-revision int
    Specific revision to observe

DESCRIPTION

kubectl rollout is a subcommand of the Kubernetes CLI tool kubectl for managing rolling updates and deployments of applications without downtime. It targets resources like Deployments, DaemonSets, and StatefulSets, leveraging Kubernetes' ReplicaSet controller to gradually replace old Pods with new ones based on updated Pod templates.

Use it to monitor rollout progress, inspect revision history, rollback failed updates, pause/resume deployments, or restart resources. For instance, after applying changes with kubectl apply, check status to ensure all replicas are updated.

This command supports strategies like RollingUpdate with maxUnavailable/maxSurge controls for safe transitions. It provides atomic rollbacks to previous stable revisions, crucial for production environments.

Integrates with Kubernetes control plane; requires cluster access and RBAC permissions for targeted resources.

CAVEATS

Limited to rollout-enabled resources (Deployments/DaemonSets/StatefulSets); inherits global kubectl flags like --namespace; requires read/write permissions on resources.

SUBCOMMANDS

history: View rollout history
pause: Pause current rollout
restart: Restart Pods by updating template
resume: Resume paused rollout
status: Watch rollout progress
undo: Rollback to prior revision

EXAMPLES

kubectl rollout status deployment/nginx
kubectl rollout history deployment/nginx --revision=2
kubectl rollout undo deployment/nginx
kubectl rollout restart daemonset/node-app

HISTORY

Introduced in Kubernetes v1.2.0 (March 2016) to streamline Deployment updates; evolved with StatefulSet/DaemonSet support in later versions; core to CNCF Kubernetes project.

SEE ALSO

Copied to clipboard