Kubernetes Deployment Strategies

Munikanth
4 min readAug 5, 2023

--

What is Deployment ??

A Kubernetes deployment ensures the desired state of your application is maintained by continuously monitoring and reconciling the actual state with the desired state. If there are any discrepancies, Kubernetes will automatically make the necessary changes to bring the application back to the desired state

Deployment Strategies

Blue-Green Deployment

Canary Deployment

Recreate Deployment

Rolling Update

A/B Testing

Shadow Deployment

Blue-Green Deployment

  • In a blue-green deployment, two identical environments (blue and green) are maintained: one for the production version (blue) and the other for the updated version (green).
  • The traffic is initially routed to the blue environment. Once the green environment is ready and tested, traffic is switched to it, effectively deploying the new version.
  • Blue-green deployments offer a quick and risk-free way to switch between versions if any issues are detected.

Canary Deployment

  • Canary deployment involves deploying the new version to a subset of users or instances, usually a small percentage.
  • This allows for testing the new version in a real environment before fully rolling it out.
  • If the new version proves to be stable, the deployment can gradually be expanded to the entire user base.

Recreate Deployment

In a nutshell, the “Recreate” deployment strategy is a straightforward approach where Kubernetes replaces all the existing pods with new ones when deploying updates. It follows these simple steps:

· Stop all existing pods: When deploying updates, Kubernetes terminates all the existing pods of the current version.

· Create new pods: Once the old pods are terminated, Kubernetes starts creating new pods based on the updated configuration, typically a new version of the application.

· No in-place updates: Unlike some other deployment strategies, there is no in-place update of pods. Instead, the old pods are entirely replaced by new ones.

· Downtime during updates: Since all pods are stopped before new pods are created, there is a brief period of downtime during the deployment process.

· Simplicity and predictability: The recreate strategy is simple to implement and easy to understand. It ensures a clean and predictable state after the update since only the new version of the pods is running.

· Limited production use: Due to the downtime involved, the recreate strategy is more suitable for applications with relatively short downtime tolerance or for non-critical environments like development or staging.

Rolling Update

A rolling update is a common deployment strategy in Kubernetes that allows you to update an application or its configuration with minimal downtime. It ensures a smooth transition from the current version to the updated version by gradually replacing instances (pods) one by one.

  • Minimizes downtime: The application remains available throughout the update process.
  • Easy rollback: If issues are encountered, Kubernetes can quickly revert to the previous version.
  • Graceful updates: Ensures that the update process doesn’t overload the system or cause service disruptions.
  • Predictable and controlled: The rolling update strategy allows you to set the number of pods updated simultaneously, controlling the rate of change.

A/B testing

  • A/B testing is a deployment strategy commonly used in marketing and product development.
  • Two or more versions of a feature or application are deployed, and users are divided into groups to test different versions.
  • The results are analyzed to determine the most effective version for wider deployment.

Shadow Deployment

  • In a shadow deployment, the new version is deployed alongside the existing version without affecting production traffic.
  • The traffic is duplicated to both versions, and the responses from the new version are logged but not sent to users.
  • This allows for monitoring the behavior and performance of the new version without impacting production users.

Each deployment strategy has its pros and cons, and the choice of strategy depends on factors such as the application’s criticality, the size of the user base, and the tolerance for risks during updates. It’s essential to carefully plan and test deployments to ensure a smooth and successful rollout.

Thank you for reading my blog 🤝Happy Learning🌟🚀🕹️

--

--

Munikanth

DevOps Engineer| DevOps| AWS certified Solution architect | CICD | Infrastrcture Automation | Docker | Kubernetes| Ansible | Terraform | Ex TCSer | Book Reader