Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
101 stars 28 forks source link

How to set placement constraints for ECS in Shippable #5131

Closed tkumark closed 4 years ago

tkumark commented 4 years ago

ECS offers 2 places where placement constraints are available on is the task definition level and service definition

Task Definition level

image

Service Definition level

image

In the documention Docker Option I only saw schedulinStrategy under service but nothing under nothing under taskDefinition.

    placementStrategy:
     - field: <string>
       type: <string>
     - field: <string>
       type: <string>
    schedulingStrategy: <string>

Should I put my placement constraints under schedulingStragtegy? Is there something for taskdefintion

a-murphy commented 4 years ago

The taskDefinition section will accept a placementStrategy, with the same fields and types as the service, but not schedulingStrategy. I think you might be looking for placementConstraints in taskDefinition, which is an array of objects with type (memberOf or distinctInstance) and expression.

tkumark commented 4 years ago

@a-murphy if were to set placementConstraints at the service level would it be like this?

service:
        placementStrategy:
         - field: attribute:appname == myapp
           type: memberof
a-murphy commented 4 years ago
service:
  placementConstraints:
    - field: "attribute:appname == myapp"
      type: memberOf

should be valid assuming you have an appname attribute on the instances. It is still placementConstraints whether it is in the task definition or service with those settings. The placementStrategy can only be binpack, random, or spread.

tkumark commented 4 years ago

@a-murphy thanks you right the appname attribute is set in the instances. I am adding at userdata echo ECS_INSTANCE_ATTRIBUTES={\"appname\":\"myapp\"} >> /etc/ecs/ecs.config;echo

tkumark commented 4 years ago

Set placement constrainst for custome attribute.

  - name: myresourceName
    type: dockerOptions
    version:
      service:
        placementConstraints:
          - expression: "attribute:appname == myapp"
            type: memberOf