Aws Eks How To

Aws Eks How To

Reading time1 min
#Cloud#DevOps#Kubernetes#EKS#BlueGreenDeployment#AWS

How to Implement Blue-Green Deployments on AWS EKS for Zero-Downtime Releases

Forget simply updating your Kubernetes pods—learn why blue-green deployments on AWS EKS are the game-changer that'll elevate your release strategy from risky to reliable, and how easily you can set it up today.

When deploying applications, one of the biggest concerns is downtime. Interrupting user access during updates leads to poor experiences, lost revenue, and, in some cases, brand damage. Zero-downtime deployments aren’t just a nice-to-have; they are critical in production. If you run workloads on AWS EKS (Elastic Kubernetes Service), mastering blue-green deployments can transform how safely and smoothly you release new versions.

Let’s dive into exactly what blue-green deployments are, why they matter in Kubernetes on AWS EKS, and a clear step-by-step practical guide to implementing them yourself.


What is a Blue-Green Deployment?

In simple terms, blue-green deployment means maintaining two identical environments:

  • The Blue environment is the live production version serving user traffic.
  • The Green environment contains the new version you want to deploy.

Instead of updating the live app in-place (which risks downtime if something goes wrong), you fully prepare and test the green environment offline. Once ready, you switch all user traffic from blue to green instantaneously, leading to zero downtime.

If anything goes wrong after switching, rollback is as easy as rerouting traffic back to blue—no complicated fixes required.


Why Use Blue-Green Deployments on AWS EKS?

AWS EKS runs Kubernetes clusters fully managed, letting you focus on building apps rather than infrastructure. However, Kubernetes' default rolling update strategy doesn’t always guarantee zero downtime if readiness probes or startup logic misbehave—or if your app requires full cache refreshes or session invalidation during deployments.

Blue-green security brings:

  • Complete isolation between versions until validation
  • Instant rollback by switching services
  • Better confidence testing against live-like production resources before exposes users

Plus, leveraging native Kubernetes constructs (like Services and Ingress) alongside AWS Route 53 makes routing traffic seamless.


Prerequisites

Before we start:

  • An active AWS account with EKS cluster running (If not setup yet, check how to create an EKS cluster).
  • kubectl configured to communicate with your cluster
  • Basic knowledge of Deployment and Services in Kubernetes
  • (Optional) Familiarity with AWS Route 53 for DNS management

Step-by-Step Guide: Blue-Green Deployment on AWS EKS

1. Prepare Your Application Deployments

Assuming you have an existing deployment named myapp, start by creating two separate deployments representing your blue and green versions.

# myapp-blue-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-blue
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
      version: blue
  template:
    metadata:
      labels:
        app: myapp
        version: blue
    spec:
      containers:
      - name: myapp-container
        image: myapp:v1 # current stable image
        ports:
        - containerPort: 80
# myapp-green-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-green
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
      version: green
  template:
    metadata:
      labels:
        app: myapp
        version: green
    spec:
      containers:
      - name: myapp-container
        image: myapp:v2 # new version you're deploying       
        ports:
        - containerPort: 80        

Apply these manifests:

kubectl apply -f myapp-blue-deployment.yaml
kubectl apply -f myapp-green-deployment.yaml 

At this point both sets of pods exist but are not being routed by any service yet.

2. Set Up a Kubernetes Service Targeting the Active Environment

Next, create a Kubernetes Service (ClusterIP or LoadBalancer depending on your use case) that routes traffic only to either blue OR green pods at a time based on label selectors.

Example routing initially to blue:

# myapp-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: myapp-service
spec:
  type: LoadBalancer   # or ClusterIP depending on how your cluster is configured 
  selector:
    app: myapp
    version: blue     # Currently routing traffic to blue pods only.
  ports:
    - protocol: TCP
      port: 80       
      targetPort: 80  

Apply:

kubectl apply -f myapp-service.yaml 

Once this service is up and has an external IP (if LoadBalancer), users receive traffic directed at the stable blue deployment.

3. Validate Your Green Environment

At this stage your green pods are running but not receiving live traffic—great for smoke testing or integration tests!

Use port forwarding or a temporary service targeting version=green:

kubectl port-forward deploy/myapp-green 8080:80 

Now visit http://localhost:8080 to verify the new application version is behaving as expected.

4. Switch Traffic From Blue to Green Version

Once happy with validation, updated live stream by changing your service selector:

kubectl patch svc myapp-service -p '{"spec": {"selector": {"app": "myapp", "version": "green"}}}'

This instantly reroutes all incoming requests on the load balancer/service IP from the old pods (blue) to new pods (green)—in under a second!

Since both deployments run side-by-side you get complete zero-downtime.

5. Clean Up Old Version or Keep for Rollback

If everything looks rock solid after some time running green:

kubectl delete deployment myapp-blue 

Or keep it running just in case you need rollback:

kubectl patch svc myapp-service -p '{"spec": {"selector": {"version": "blue"}}}' 

and switch back any time quickly without reinstall or recreate steps.


Bonus Step – Automating with CI/CD Pipelines

For real teams pushing frequent updates consider automating this process using tools like AWS CodePipeline + CodeBuild or Jenkins combined with kubectl commands & Helm charts scripts that trigger:

  • Deploy green environment images
  • Run integration smoke tests against green pods
  • Route service from blue→green automatically after tests pass

This smooths out manual steps and accelerates confident releases drastically.


Wrapping Up

Implementing blue-green deployments on AWS EKS gives your team supreme control and confidence during releases—no more praying that rolling updates won’t break production mid-day! This technique pairs perfectly with Kubernetes’ capabilities and Amazon’s managed infrastructure so you can safely ship features at scale with zero downtime.

Give it a try today using this guide—you’ll never want to deploy any other way again!


If you're interested in more detailed examples including DNS switchovers via Route53 or using Ingress Controllers like ALB for even smoother user experiences let me know—I can share those next!

Happy deploying! 🚀