Terraform से AWS EKS Blue Green Deployment कैसे करें?

Опубликовано: 04 Август 2026
на канале: Computer Pathshala
157
7

Create AWS EKS cluster using terraform and deploy Nginx using Blue green deployment method on EKS Cluster.

we can switch traffic between blue and green in different ways.

Use the kubectl patch commands to switch traffic between the blue and green deployments.
To switch traffic to the blue deployment:

kubectl patch service nginx-service -p '{"spec":{"selector":{"version":"blue"}}}'
To switch traffic to the green deployment:

kubectl patch service nginx-service -p '{"spec":{"selector":{"version":"green"}}}'
Initially, configure the service to point to the blue deployment. means we can create single service yaml file and use labels of deployment to switch between blue and green.

example:

in blue and green deployment yaml file we will add a labels as below under spec: selector:

version: blue
version: green
simillarly we can update selector using same labels in service yaml file and apply configuration.

kubectl apply -f service-blue.yaml

To switch traffic to the green deployment, update the service selector.

kubectl apply -f service-green.yaml