- Take me to Video Tutorial
In this section, we will take a look at rolling updates and rollback in a deployment
-
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
- 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
- To undo a change
$ kubectl rollout undo deployment/myapp-deployment
- To create a deployment
$ kubectl create deployment nginx --image=nginx
$ 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