Member-only story
Kubernetes (k8s) Deployment Strategies

Recently, most companies are inside that migrating from monolith systems to microservices. Meanwhile, nobody wants to cut instantly old applications and bring the new ones to production. Generally, when an old application is in production, new ones deploy to production same time. And both applications (old and new ones) work in parallel on production. After then if everything is working clearly and well, old applications will be able to shut down.
On the other hand, we are now in a period where continuous delivery and agility are important for companies. Every company wants to deploy more than one feature to production at the same time and same day. Of course, every feature is important, but we may want to try some features live. (such as A/B testing in production)
If we are using Kubernetes, this article will explain how we should make these feature deployments securely to production.
1- Recreate
It means, you can think that pods that are running on production will be terminated, after then new pods will be getting up with a new version.
I would like the underline that, during this deployment strategy time our application won’t be accepting any requests. While pods are getting up, it has a warm-up time. And also during this warm-up time, our application will be unavailable. Never recommended for sites that are expected to be available 7/24. (e-commerce sites, job boards, etc.)
Usage; We just need to add the following commands in our YAML file.
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: your namespace
spec:
replicas: 1
strategy:
type: Recreate

2- Rolling Update (Ramped Slow-Rollout) Deployment
In this strategy, new pods are created and old pods are deleted in such a way that the defined number of replicas in the YAML file. Once all the new pods are created older pods are terminated.
As we use this strategy, we need to pay attention to these two terms.