What is Deployment?
It manages the application by creating & managing replica sets; Deployments always keep tabs on the Application inside the Cluster and try to maintain the Current vs Desired State of the Application inside the Cluster.
When to use Deployment?
Deployment acts as a Superset to Replicaset (ensures a specific number of Pods are always running). Deployment contains features like rolling updates, rollbacks, version history, replicas, etc.
Strategies of Deployments
These are some of the strategies used for the application deployments based on the Requirements and the Fault Tolerance where each strategy offers uniqueness leading to some tradeoffs in terms of speed of deployment, and resource utilization.
A. Recreate Deployment
Recreate is a quite simple strategy where the Pods are terminated before the new ones are created this results in the unavailability of the application i.e. Downtime of the application (which is not preferred for a Production Grade Application that needs to be Highly Available)
B. Rolling Update Deployment
Rolling Update is the default Deployment Strategy in K8s it ensures minimal downtime of the Application; here the set of Pods are updated gradually with the new ones, ensuring that the application remains Highly Available and serves traffic at all times.
We can have control over the number of pods that can remain unavailable using the maximum unavailable and add the number of additional pods using the maximum surge.
In case of any issues, we can roll back easily to the previous stable version (build) of the application.
C. Blue-Green Deployment
This strategy is used to provide minimal downtime where two separate environments are maintained;
Blue Environment: It contains the previous stable deployment
Green Environment: It contains the new Deployment / Revised Deployment i.e. the newer deployment versions to upgrade to.
In Blue-Green initially, all the traffic is routed to the Blue Environment via the Load Balancers while the other Green Environment contains the newer version of Deployments.
After thorough testing (Automated, Performance, UAT) and getting a nod from the Stakeholders then the traffic can be switched from Blue to Green Environment by routing the Load Balancers to Green Environment. Further either Decommissioning the Blue Environment or Keep it as a backup until confident about the Green Environment
But certain things need to be taken care of like the Rollback Plan (in case of any critical issues) and monitoring the green environments post-switching to check for any anomalies.
In the case of the Rollback for Blue-Green Deployment could be handled easily by diverting the traffic back to Blue Environment (previous stable deployment)
D. Canary Deployment
Canary deployment is a Kubernetes (K8s) strategy to release new versions of an application made available to a subset of users or traffic, allowing for testing and validation before rolling out the changes to the entire user base.
We deploy two versions of the Application i.e. Baseline (Stable) and Canary (Newer Version) while the Load balancer is used to Split the traffic between the Environments
In Canary Deployment the Notion is to initially route some traffic (5 to 10%) to the Canary Deployment and monitor the Canary build stability after receiving the traffic, getting the Canary Build User Feedback; If all goes smoothly then increase the traffic towards the Canary Build.
Here we also need to take care of the Rollback Plan (in case of any critical issues), monitor the Canary Build (check out the anomalies) during the incremental rollout, and increase the percentage of traffic routed to Canary to make it available to the full set of users.
Considering the Case of the Rollback for Canary Deployment could be handled easily by diverting the incrementally back to the baseline version or Redirecting all the traffic at once back to the baseline version (scraping the Canary Deployment and redeploying after troubleshooting the Deployment Failure)
Conclusion:
Each Deployment Strategy has its unique benefits; selecting the Deployment Strategy depends on the Application Requirement, Organization Compliance, and update mechanisms while maintaining the High Availability, Reliability, and Agility for Application present in the K8s Cluster.
EzyInfra.dev is a DevOps and Infrastructure consulting company helping clients in Setting up the Cloud Infrastructure (AWS, GCP), Cloud cost optimization, and manage Kubernetes-based infrastructure. If you have any requirements or want a free consultation for your Infrastructure or architecture, feel free to schedule a call here.
Share this post