I have an autoscaling group with the following settings:
- name: configure auto-scaling group
ec2_asg:
name: "{{ application_name }}-{{ application_environment }}-auto-scaling-group"
availability_zones:
- "{{ region }}a"
- "{{ region }}b"
- "{{ region }}c"
state: present
launch_config_name: "{{ application_name }}-{{ application_environment }}-launch-configuration"
min_size: 1
max_size: 2
region: "{{ region }}"
desired_capacity: 2
tags:
- environment: "{{application_environment}}"
vpc_zone_identifier:
- "{{ vpc.subnets[0].id }}"
- "{{ vpc.subnets[1].id }}"
- "{{ vpc.subnets[2].id }}"
It's spinning up two ec2 instances.
On both instances, there is a service running with an nginx listening to port 80. I understand that I cannot use port 80 twice. The service has a desired capacity of 2, but I'm willing to have one running during rolling-updates.
However, if i update the service and task definition, I get the following error:
ERROR: (service myapp-testing-service) was unable to place a task because no container instance met all of its requirements. The closest matching (container-instance 24d9d97e-c979-41a3-a438-212390612ae3) is already using a port required by your task. For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.
It's true, the port is blocked. What I want to happen in that case is that one nginx-service is taken down, the new is taken up, the other one is taken down after that and replaced with the new one.
I thought that this is the default behaviour, but it looks like it isn't - or do I get something wrong?
You will need to reconfigure your ECS service configuration for myapp-testing-service
.
Set the Minimum healthy percent to 50.
This will allow your service to RUN 1 task of the old version when deploying the new version.