How to: Rollout and Rollback <a name="rollout-rollback"></a>
- Rollout and Rollback enable to update and return back containers that run under the deployment.
- 2 strategy for rollout:
    - **Recreate Strategy:** Delete all pods first and create Pods from scratch. If two different versions of SW affect each other negatively, this strategy could be used.     
    - **RollingUpdate Strategy (default)**: It updates pods step by step. Pods are updated step by step, all pods are not deleted at the same time.
        - **maxUnavailable:** At the update duration, it shows the max number of deleted containers (total:10 containers; if maxUn:2, min:8 containers run in that time period)
        - **maxSurge:** At the update duration, it shows that the max number of containers run on the cluster (total:10 containers; if maxSurge:2, max:12 containers run in a time)
    
```shell
kubectl set image deployment rolldeployment nginx=httpd:alpine --record     # change image of deployment
kubectl rollout history deployment rolldeployment                           #shows record/history revisions 
kubectl rollout history deployment rolldeployment --revision=2              #select the details of the one of the revisions
kubectl rollout undo deployment rolldeployment                              #returns back to previous deployment revision
kubectl rollout undo deployment rolldeployment --to-revision=1              #returns back to the selected revision=1
kubectl rollout status deployment rolldeployment -w                         #show live status of the rollout deployment
kubectl rollout pause deployment rolldeployment                             #pause the rollout while updating pods 
kubectl rollout resume deployment rolldeployment                            #resume the rollout if rollout paused
```
  
**Goto the Scenario:** [LAB: K8s Rollout - Rollback](https://github.com/omerbsezer/Fast-Kubernetes/blob/main/K8s-Rollout-Rollback.md)