I am trying to use codedeploy service to deploy code along with load balancer because i want codedeploy to deregister and register instances while deploying, making sure that no requests are dropped while deploying. But my architecture is that
I have 4 instances, each running 3 application processes at 3 different ports for example
Instance 1: app1 at port 81, app2 at port 82, app3 at port 83
Instance 2: app1 at port 81, app2 at port 82, app3 at port 83
Instance 3: app1 at port 81, app2 at port 82, app3 at port 83
Instance 4: app1 at port 81, app2 at port 82, app3 at port 83
All these instances and their ports are registered to target group which is being used in codedeploy.
And i configure it to deploy one instance at a time
But when i deploy using codedeploy, it hangs after it de-registering 1st port in 1st instance it picked.
NOTE:
1) App1, App2, App3 are all same, just running on different ports for high availability, so code is also same and start/stop scripts are also same
2) Not using auto scaling group, registered ec2 instance using key-value pair, enabled load balancing by selecting application load balancer and gave targetgroup to which those ec2 instances were registered
2) Deploying on In-place deployment
Problem to be solved: Deregistering all ports and deploy and register all ports in each instance in single deployment and repeat this in all 4 instances
So is there a way to configure application deployment at different ports in an instance using load-balancer?
1 Answer
If I understand the situation correct, you have 3 applications running on the same 4 instances using a separate port per application to serve traffic. Since you can only have 1 port per target group, I assume that you have 3 target groups as well. Given your description, it sounds like you deploy all 3 applications using the same CodeDeploy application, presumably bundling it all together.
Only one target group per deployment
Given you're situation, it's not possible to have one CodeDeploy deployment bind/unbind from 3 different target groups in the same deployment. The restriction is one target group per deployment, so it's not possible to bind/unbind from 3 different ports. Of course, you could do all of this manually using lifecycle hooks, but I would highly discourage that.
Use a different CodeDeploy application per application
What it really sounds like you need to do is create a separate CodeDeploy application for each application you're running. If you broke it out into 3 different applications in CodeDeploy, you don't have this problem at all because you'll have 3 different deployment groups with three different target groups, all bound to different ports. Your release process will be much safer because you only risk updating one application at a time instead of 3, and when you do a deployment, you only need to unbind from the target group serving 1 application, so the other 2 applications will continue running. This should increase your availability.
The only downside to this approach is more deployments with the benefit of increased safety, and you won't be able to release all 3 applications at once, if there was some reason you needed to do that.