Creating Deployment Version 2

Create a new file dep-v2.yaml with the following content,

apiVersion: apps/v1
kind: Deployment
metadata:
name: dep-v2
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: dep-v2
template:
metadata:
labels:
app: dep-v2
spec:
containers:
- image: guybarrette/hello-app:2.0
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 250m
memory: 256Mi
imagePullPolicy: Always
name: dep-v2
ports:
- containerPort: 8080

This is the same as the dep-v1.yaml, except that the hello app version is 2.0.

We can use below command to deploy this too,

kubectl apply -f dep-v2.yaml

At this point, we have deployed both version of the apps but we are currently forwarding our live traffic to deployment version 1 only,

What is Kubernetes Blue Green Deployment?

Blue-green deployment is a software deployment strategy that involves running two identical production environments, known as “blue” and “green.” At any given time, only one of these environments serves live traffic, while the other remains idle or serves only non-production traffic (e.g., testing or staging).

Similar Reads

What is Kubernetes?

Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications....

What is a Deployment in Kubernetes?

In Kubernetes, a Deployment is a resource that manages the lifecycle of an application by defining its desired state. It provides declarative updates for Pods (the smallest deployable units of computing) and ReplicaSets (which ensure the desired number of replicas are running)....

What is a Service in Kubernetes?

A Kubernetes Service is an abstraction that defines a logical set of Pods and a policy by which to access them. It acts as a stable endpoint for accessing the applications running in a Kubernetes cluster, regardless of the underlying Pod’s IP address or location within the cluster....

What is Blue-Green Deployment in Kubernetes?

the is a deployment strategy used in Kubernetes to minimize downtime and reduce the risk associated with deploying new versions of an application. It involves running two identical production environments, referred to as “Blue” and “Green,” where only one environment is live at any given time....

Create Deployment Version 1

This will act as our current stable version of the application. We will create a deployment for this and use the publicly available (guybarrette/hello-app) docker image available on the docker hub....

Creating a Service

In order to access our application from the outside world, we need to make use of a Kubernetes service. It will select all pod having app: dep-v1 selector....

Creating Deployment Version 2

Create a new file dep-v2.yaml with the following content,...

Switching Traffic to Deployment Version 2

We can update our service.yaml as below....

Kubernetes Blue Green Deployment – FAQ’s

What are the main benefits of using Blue-Green Deployments?...