hackoregon / civic-devops

Master collection point for issues, procedures, and code to manage the HackOregon Civic platform
MIT License
11 stars 4 forks source link

add placement strategies to API service/task definitions. #165

Closed iant01 closed 6 years ago

iant01 commented 6 years ago

this need to be done after the other ECS changes have been implemented. Issues #145 #163 #164. (issue 145 is the primary one but all three can be applied at same time) The placement strategy needs the updated ecs agent and without issue 145, there is a chicken and the egg problem.

This needs to be added to each API service.yaml file and should result in service tasks being evenly spread across availability zones and instances within a zone in the ECS cluster. PlacementStrategies:

And needs to be in the Resource - service section:

Service:
    Type: AWS::ECS::Service
    DependsOn: ListenerRule
    Properties:
        Cluster: !Ref Cluster
        Role: !Ref ServiceRole
        DesiredCount: !Ref DesiredCount
        TaskDefinition: !Ref TaskDefinition
        PlacementStrategies:
          - Type: spread
            Field: attribute:ecs.availability-zone
          - Type: spread
            Field: instanceId

        LoadBalancers:
            - ContainerName: "civic-2017-service"
              ContainerPort: 3000
              TargetGroupArn: !Ref TargetGroup
iant01 commented 6 years ago

changes committed to branch issue#165-add-service-placement-strategy but holding off on pull request until ecs pulls are merged and implemented.

MikeTheCanuck commented 6 years ago

This was PR'd and merged via: https://github.com/hackoregon/hackoregon-aws-infrastructure/pull/38

Unfortunately the resulting changeset rolled back.

MikeTheCanuck commented 6 years ago

This specific work finally "took" once we (a) had Michael Lange execute the changeset and (b) temporarily turned off the 2GB monster that is the 2017 transportService: https://github.com/hackoregon/civic-devops/issues/175#issuecomment-397897198

MikeTheCanuck commented 6 years ago

And now we're implementing the second half of this strategy, per PR 41

MikeTheCanuck commented 6 years ago

And that went through as well, so we are in business (excepting a weird anomalous regression on the EC2 AMI that we're correcting, maybe manually)