Skip to content

Latest commit

 

History

History
100 lines (82 loc) · 2.41 KB

File metadata and controls

100 lines (82 loc) · 2.41 KB

Rolling Updates and Rollback

In this section, we will take a look at rolling updates and rollback in a deployment

Rollout and Versioning in a Deployment

rollv

Rollout commands

  • You can see the status of the rollout by the below command

    $ kubectl rollout status deployment/myapp-deployment
    
  • To see the history and revisions

    $ kubectl rollout history deployment/myapp-deployment
    

    rollc

Deployment Strategies

  • There are 2 types of deployment strategies

    1. Recreate
    2. RollingUpdate (Default Strategy)

    dst

kubectl apply

  • To update a deployment, edit the deployment and make necessary changes and save it. Then run the below command.
    apiVersion: apps/v1
    kind: Deployment
    metadata:
     name: myapp-deployment
     labels:
      app: nginx
    spec:
     template:
       metadata:
         name: myap-pod
         labels:
           app: myapp
           type: front-end
       spec:
        containers:
        - name: nginx-container
          image: nginx:1.7.1
     replicas: 3
     selector:
      matchLabels:
        type: front-end       
    
    $ kubectl apply -f deployment-definition.yaml
    
  • Alternate way to update a deployment say for example for updating an image.
    $ kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
    
    ka

Recreate vs RollingUpdate

rcrl

Upgrades

up

Rollback

rb

  • To undo a change
    $ kubectl rollout undo deployment/myapp-deployment
    

kubectl create

  • To create a deployment
    $ kubectl create deployment nginx --image=nginx
    

Summarize kubectl commands

$ kubectl create -f deployment-definition.yaml
$ kubectl get deployments
$ kubectl apply -f deployment-definition.yaml
$ kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
$ kubectl rollout status deployment/myapp-deployment
$ kubectl rollout history deployment/myapp-deployment
$ kubectl rollout undo deployment/myapp-deployment

sum

K8s Reference Docs