Hello everybody and welcome back to the Cognixia podcast! We are still wrapping our heads around the fact that one month of 2023 is already over and we are already in February 2023! How time flies, people, isn’t it?
Well, it is what it is, and time & tide do wait for none, after all. So, let’s get down to making the most of the time right now and begin this week’s episode.
This week, we talk about Kubernetes deployment strategies. We talk about what is Kubernetes in a lot of our episodes. Kubernetes is a very popular open-source container orchestration system for automating software deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation.
Now, there are quite a few different ways in which an application can be released in Kubernetes. One must pick whatever approach works for them, meets their requirements, and ensures the dependability of their infrastructure when the updates to the application are rolled out. This becomes a bigger issue when there are frequent releases and updates and would have a major impact on application dependability as well as customer experience. For effective risk management, it is essential that DevOps teams in the organization create protocols and closely monitor the deployment plans.
Let’s take a quick minute to understand what is deployment in Kubernetes. In Kubernetes, a deployment is a resource object that specifies the final state of a program. Deployments are declaratory so the state to be achieved is not usually specified. Instead, the desired configuration must be specified. The deployment controller can manage things with that information and complete the tasks automatically in the best possible way. A deployment can be used to specify the entire process of an application, even cover the images to be used, the number of pods required, and how they would need to be modified.
As we mentioned before, in this episode we will be talking about the Kubernetes deployment strategies, so what are the different deployment strategies in Kubernetes?
A deployment strategy would specify how to update and develop the different Kubernetes application versions. Kubernetes deployment strategies offer users ways to minimize downtime and interruptions that would be caused by rolling out upgrades and deploying the applications. So, let us take a quick look at the different Kubernetes deployment strategies.
The first Kubernetes deployment strategy we talk about is Rolling Deployment. This is, as a lot of you would know, the default deployment method for Kubernetes. In this method, every pod from the previous version of the application would gradually get replaced by a pod from the new version. A readiness probe is also involved in this deployment strategy to check if the new pod is ready. The good thing here is that the entire cluster does not get stopped for the deployment, and a user can easily top an upgrade being rolled out and recall it if a problem is discovered.
The next deployment strategy we talk about is the Canary Deployment. This deployment strategy involves testing new software on a limited amount of real traffic before going ahead to deploy it to the Kubernetes cluster. The key benefit of this deployment strategy is that it lets one test a new upgrade or say a new experimental feature on a small group or a small number of live users, while all the other users can continue using the existing version of the application. In this way, nobody’s operations or use is affected. The highlight here is that both the older version of the application as well as the new version of the application with the new features are being deployed concurrently. This strategy works very well for times when you need users to gradually switch to the new version and you can keep collecting feedback by testing the new features on a small live audience.
Are you with us so far? I am sure, you are! So, let us move on to the third Kubernetes deployment strategy we discuss – the Recreate Deployment. A recreate deployment is a fully featured procedure that works best for fast and brief program updates. In this strategy, the deployment’s current pods are terminated and the new version would be installed in their stead. The problem here is that during the time this process takes place, the application would be unavailable for the users. Once the fresh pods are launched, the application will be available again. So, there will always be some downtime when using the Recreate deployment strategy, so this strategy works when you are working with software that can accept maintenance downtimes and interruptions, especially the ones that are not-so-critical. However, when dealing with an application that has strict policies or is extremely critical to operations, we would recommend choosing some other Kubernetes deployment strategy.
But this makes you wonder why would anybody want to use this strategy at all, who likes downtime after all? The Recreate deployment strategy is commonly used by DevOps teams in the development phase since it is really simple to set up and it also completely renews the state of the application with each latest version.
The fourth popular Kubernetes deployment strategy e would like to talk about is the Blue/Green deployment. This deployment strategy uses color coding of the versions for distinction and deployment. The current version of the application would be represented by blue while the new version of the application would be represented by green. However, only one either the blue or the green version can be active at a time in this deployment strategy. When construction and testing are ongoing in the green version, the blue version would be active. Once the construction and testing are complete, the traffic is diverted to the green version. This helps eliminate downtimes because if you need to go back to working on the new version, the old version becomes active immediately and operations can continue smoothly for all users. The entire application state is in a single deployment so versioning issues are also eliminated. The limitation of this Kubernetes deployment strategy is that it requires twice the resources and can prove to be quite expensive. One would also need to have the means to make quick switches between the blue and green versions.
Coming to the last Kubernetes deployment strategy we discuss today – A/B deployments. Just as in marketing, Kubernetes deployments have A/B testing and deployments too. Here, the traffic is routed to different application versions depending on some defined criteria. These targeting criteria can be based on cookies, users, or other parameters. This is where this strategy differs from regular canary deployments, as the latter routes the users simply based on the traffic weights. A/B deployments work very well when important corporate decisions need to be informed where the traffic can be routed based on the information derived from user behavior data. A/B deployments do not disclose the new upgrades or features to the features, so the testing is quite objective. However, they also call for a longer time for rollouts as more testing and er analysis is usually essential here.
Well, those are the main Kubernetes deployment strategies that get used and some pointers on when to use what, as well as some information about what each strategy is all about. To sum it all up, we can say when you are distributing to a development/staging environment, a recreate deployment would be a smart choice. When in a production state, blue/green deployments work well. Canary deployments can be chosen if you are not fully sure about the platform’s stability or are skeptical about the potential effects of launching a new software version. In this way, we enable user testing of the application and platform integration. By integrating deployments with all the other Kubernetes functionalities, users can build more reliable containerized apps to meet any need at hand.
With that, we come to the end of this week’s podcast episode. We hope you enjoyed listening to us. If you have any questions or suggestions, drop us a line on any of our social media handles. With the new month starting, we are also running some superb promotions on our live online instructor-led courses, so do check them out, and take the leap towards transforming your career with Cognixia.
Until next week then, happy learning!