I have ecs which service has two same tasks for load balaner.
And this taskdefition has two container from ECR
repository
Now I want to restart the two tasks via aws cli
after updating ECR
repository.
I try this
aws ecs update-service --force-new-deployment --service myservice --cluster mycluster
However, it starts the new two tasks but, old two tasks doesn't stop so ,there comes four tasks.
How can I restart the two tasks, not adding two tasks.
CodePudding user response:
The old tasks will be stopped after the new ones become healthy. You can also set the maximum percent to 100, so that it will stop the old tasks before launching new ones, and will not have more running tasks than the desired task count.
From the docs:
maximumPercent
If a service is using the rolling update (ECS) deployment type, the maximumPercent parameter represents an upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount (rounded down to the nearest integer). This parameter enables you to define the deployment batch size. For example, if your service is using the REPLICA service scheduler and has a desiredCount of four tasks and a maximumPercent value of 200%, the scheduler may start four new tasks before stopping the four older tasks (provided that the cluster resources required to do this are available). The default maximumPercent value for a service using the REPLICA service scheduler is 200%.