Blue/Green on Fargate Load Balancer swap Target Group after deploy

0

Hi all,
we are setting up a service to AWS Fargate, we want to use a Blue/Green deployment.
We have an Application Load Balancer, and two Target Group, and also we have setup a CodePipeline.
The code Pipeline connects to our bitbucket repository, and build the Docker image of our service with no problem. It then add two artifacts "taskdef.json" and "appspec.yaml" that we use to deploy the app.
On the Load Balancer we have setup two Listener, on port 80 forwarded to TargetGroup1, on port 8081 forwarded to TargetGroup2.
The Deployment Group has port 8081 as Test listener port.
It all works on first time deploy, it test the new service on TargetGroup2, and deregister the service on TargetGroup1.
After the deployment the new service is registered to TargetGroup2 and BOTH the listener 80, and 8081 are forwarded to TargetGroup2.
THIS IS WHERE PROBLEMS CAMES IN.
This means the next time we deploy the "Stage 2: Test traffic route setup" will "skip" cause the status of the listener on TargetGroup1 is "Target group is not configured to receive traffic from the load balancer". This will take the Deploy directly to the next stage, that change the Load Balancer listener on BOTH port forwarding to TargetGroup1, but our service is still "initializing" and not in a "Healty" status.
I though after the deploy the testing port would be forwarded (swapped) back to the not blue group.
I'm for sure missing something, can someone please show me where I make wrong things.

Thank you!

已提问 3 年前720 查看次数
1 回答
0

Think I've solved using Lambda.
The trick was to wait an healthy status during the deploy process.
On my appspec.yaml I've declared a function to be called AfterAllowTestTraffic
AfterAllowTestTraffic: "CodeDeployAATT-myappname-production"
This function will wait for the healthy target on the green trunk.
Find below the functions used.
https://gist.github.com/sb-davidegironi/36ad718da81c7ae89618c55e3f941c8d

已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则