The kubectl rollout command is used to manage rollouts of deployments in a Kubernetes cluster. It allows you to deploy new versions of your application, roll back to previous versions, and view the status of rollouts. Here’s how you can use the kubectl rollout command:

kubectl rollout {{command}} {{resource_type}}/{{resource_name}}

Replace {{command}} with the specific action you want to perform, such as status, history, pause, resume, undo, or restart. Replace {{resource_type}} with the type of resource you want to manage rollouts for (e.g., deployment, statefulset, etc.), and {{resource_name}} with the name of the specific resource.

Here are a few examples:

  1. Get the status of a rollout:
kubectl rollout status deployment/my-deployment

This command displays the status of the rollout for the deployment named my-deployment, including the current replica set, the number of available replicas, and the rollout progress.

  1. View the rollout history:
kubectl rollout history deployment/my-deployment

This command shows the revision history of the deployment named my-deployment, including the revision number, the date of the revision, and any annotations associated with each revision.

  1. Pause a rollout:
kubectl rollout pause deployment/my-deployment

This command pauses the rollout of the deployment named my-deployment, preventing any further updates to the deployment.

  1. Resume a paused rollout:
kubectl rollout resume deployment/my-deployment

This command resumes a previously paused rollout of the deployment named my-deployment, allowing updates to proceed.

  1. Rollback to a previous revision:
kubectl rollout undo deployment/my-deployment --to-revision=2

This command rolls back the deployment named my-deployment to the revision specified by --to-revision. In this example, it rolls back to revision 2.

Remember to replace the placeholders ({{}}) with the actual values specific to your use case. Additionally, ensure that you have the kubectl command-line tool installed and properly configured to connect to your Kubernetes cluster.

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐