Blue-Green Deployment Strategy
The Blue-Green Deployment focuses on running two identical environments, referred to as blue and green. An important point to note is that both these environments run concurrently. The blue environment represents the current production version of the application, while the green environment represents the new version being deployed.
- The following YAML can be used to implement this kind of deployment:
apiVersion: v1
kind: Service
metadata:
name: my-app-service
labels:
app: my-app
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: my-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-blue
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
color: blue
spec:
containers:
- name: my-app-container
image: my-image:blue
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-green
spec:
replicas: 0
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
color: green
spec:
containers:
- name: my-app-container
image: my-image:green
Use Case For Blue Green Deployment: This deployment is suitable for applications where zero downtime is important so that we can quickly rollback to the previous version is essential.
What Are The Kubernetes Deployment Stratagies ?
Traditionally, applications used to be deployed on the Physical Servers. However, it was not very efficient as multiple instances of the applications running on the server used to consume a lot of resources. Although Virtual Machines running on the Servers tried to solve the issue, resource allocation and slow boot times were still problems. Due to this, Containerization Technologies like Kubernetes came into the picture.
In this article, we will learn in detail about the deployment strategies in Kubernetes that will help us to understand why it is one of the most popular choices among Software Experts. So, let us start without any delay.