September 21, 2022

Kubernetes Application Deployment Strategies

Table of Contents

Kubernetes supports various deployment strategies like rolling, canary, and blue/green to manage updates smoothly. Rolling deployments continuously update nodes, canary releases test changes with a subset of users, and blue/green deployments switch traffic between environments. Each strategy minimizes risks and ensures reliable application delivery.

When you are ready to deploy your production-ready containerized applications into Kubernetes, you are required to choose a deployment strategy. Your choices are rolling (which is the default), canary releases, or blue/green deployments. These deployment strategies are all commonly used by developers as a way to roll out new code changes smoothly and safely in production environments. Kubernetes makes it easy to deploy new versions of your applications. This blog post explores the differences between these three commonly used application deployment methods: rolling, canary, and blue/green. Let’s look at what each of these Kubernetes deployment strategies offer and when you should use them.

Rolling Deployment

The image shows the before and after states of rolling deployment.

A rolling deployment is a continuous process for deploying updates to your application in production and this is the default as a Kubernetes application deployment strategy. Typically, you will continually be deploying new code changes to all of your nodes in a rolling fashion. This process involves deploying a new version of your application, followed by a monitor/wait period. During this waiting period, you would monitor the health of your production nodes for anomalies. If everything looks good, you will proceed to the next set of nodes and then the next set of nodes until all of the nodes are updated with the new code. 

A rolling deployment strategy is an approach to continuously deploying new code changes to all the nodes in production in a rolling fashion. The Harness platform makes it easy for developers to use the rolling deployment strategy so they can deploy their software with minimal risk. 

The image shows the Step Library of the Harness platform.
The image shows the Step Parameters of the Kubernetes rollout.

Once the configuration is set up, you can apply changes and run the pipeline, you should see the rolling deployment strategy getting executed as you have specified it. 

Learn more about rolling deployment here

Canary Deployment

The image shows the before and after states of canary deployment.

Canary releases are a way of managing risk by rolling out a new code or configuration change to production in stages. Canary releases are the first stage of a multi-stage rollout where you deploy a small percentage of a new change to a subset of your users. A canary release is basically a controlled rollout that can help you minimize risk. A canary release strategy is ideal for testing a new code change in production without impacting every user. It allows organizations to deploy the new features to a small percentage of their overall user base and monitor their behavior to identify potential issues and initial responses/feedback. If everything looks good, organizations can proceed with a multi-stage rollout to a more significant percentage of their users. It is a technique used by developers to ensure that new releases haven’t broken anything in the application, and it is also used to monitor the health of production systems.

The Harness platform supports the canary deployment strategy and can be easily configured with just a few clicks.

Assuming you have configured your pipeline with all the other requirements, in the execution stage of the deployment, you can specify the deployment strategy type as shown below.

The image shows the Continuous Deployment screen of the Harness platform.

The image shows the Continuous Deployment screen of the Harness platform.

The image shows the step library in the Harness platform.

Once the configuration is set up, you can apply changes and run the pipeline. You should see the canary deployment strategy getting executed as you have specified.  

Learn more about canary deployments here.

Blue/Green Deployment

The image shows the before and after states of the blue/green deployment.

The blue/green deployment strategy is where you create two distinct but similar environments. One environment (blue) runs the current application version, and the other (green) runs the new application version. Then you gradually transfer user traffic from the blue environment to the green environment without affecting the services. The blue/green deployment strategy is well-practiced in the industry because it reduces the risk of downtime as both environments are almost identical. Also, instead of waiting for less user traffic for the new code deployment, with blue/green, you can do the deployment during peak times without worrying about user traffic. 

Harness helps to accomplish your goal of blue/green deployment by easily configuring it to your application deployment strategy.

The image shows the continuous deployment screen of the Harness platform.

The image shows the step library in the Harness platform.

Selecting stage deployment for blue/green deployment.

The image shows the blue/green deployment option in the Harness platform.

The image shows the blue/green deployment option.

You can apply these changes, and save and run the pipeline to execute our blue/green deployment.

Learn more about the blue/green deployments here.

Conclusion

A production-ready Kubernetes deployment requires careful planning and execution. You can accomplish this by selecting a deployment strategy suited to the type of application you are deploying. Choosing the right deployment strategy is also based on the architecture you have,  such as monolithic, microservices or serverless. Each deployment strategy has its own benefits, so it’s essential to choose the one that fits the needs of your application and team. In addition, these deployment strategies help organizations maintain their uptime and gather initial feedback from customers. They also reduce the risk of deploying faulty code or a faulty feature into production. You should also have a modern delivery platform like Harness that can handle your deployments easily by providing you with all the deployment strategy options. 

To learn more about how Harness can help you with deployments, visit https://harness.io/products/continuous-delivery

Continuous Delivery & GitOps