Rolling updates and Rollbacks in Kubernetes deployment
Kubernetes provides rollout options to do update on deployment and easily fallback to any revision. We are going to see how to update the deployment to a newer version of container image and rollback to previous version without affecting the services
Setup
I am using the Virtualbox(running in Ubuntu 18.04 physical machine) for this entire setup . The physical machine is Dell inspiron laptop with 12GB RAM , Intel® Core™ i7-6500U CPU @ 2.50GHz × 4 and 512GB SSD hardisk.
Step 1: Create a deployment
Step 2: Export the deployment to yaml file and add the port option(for nginx image the port is 80)
Step 3: Apply the changes to the deployment
Step 4: Expose the deployment as ClusterIP
Step 5: Verify the service by accessing nginx deployment using the ClusterIP
Step 6: Verify the current version of Nginx
Go to the kubernetes node kubernetes2 and verify the nginx version
Now we have made 2 changes to the nginx deployment
Orignal Nginx deployment
Nginx deployment with container port set as 80
Step 7: set Nginx with a different image version
Verify the nginx version in node kubernetes2
Now the nginix version is changed from 1.17.6 to 1.9.1
Step 8: Verify the service by accessing nginx deployment using the ClusterIP
Step 9: Verify the rollout history
Now we have made 3 changes to the nginx deployment
Step 10: Now rollback to older revision and verify the nginx version changes
Now the nginix version is changed from 1.9.1 to 1.17.6
Step 11: Verify the service by accessing nginx deployment using the ClusterIP
We successfully done the rollout in nginx deployment
Discussion and feedback