One useful feature of deployments is the ability to track the rollout history. To view rollout history, use the following command:
kubectl rollout history deployment/nginx
You will see output something similar to this.
deployment.apps/nginx
REVISION CHANGE-CAUSE
1 <none>
2 <none>
3 <none>
We can get details on a particular revision with:
kubectl rollout history deployment.v1.apps/nginx --revision=1
Output:
deployment.apps/nginx with revision #1
Pod Template:
Labels: app=frontend
pod-template-hash=776567f984
Containers:
nginx:
Image: nginx:latest
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Rolling Back a Deployment
Suppose you have made some changes to your deployment that you want to roll back. To do this, use the following command:
kubectl rollout undo deployment/nginx --to-revision=3
Output:
deployment.apps/nginx rolled back
Also check the pods list, you will see following output, where deployment controller trying to reconcile the status.
kubectl get pods -l app=frontend
NAME READY STATUS RESTARTS AGE
nginx-68d45cc4b6-cm2hz 1/1 Running 0 85s
nginx-68d45cc4b6-dkwd8 1/1 Running 0 81s
nginx-68d45cc4b6-pzkx7 1/1 Running 0 85s
nginx-68d45cc4b6-znqgn 1/1 Terminating 0 82s
nginx-74bb7f5f9f-ds8qs 0/1 ContainerCreating 0 2s
nginx-74bb7f5f9f-g4nqq 1/1 Running 0 2s
nginx-74bb7f5f9f-rdl5h 0/1 Pending 0 0s
nginx-74bb7f5f9f-rrbfs 0/1 ContainerCreating 0 2s
Top comments (1)
Very helpful materials.