speee / webapp-revieee

MIT License
39 stars 2 forks source link

SpotFleet対応 #6

Closed selmertsx closed 7 years ago

selmertsx commented 7 years ago

ここらへん読んでる

http://aws.typepad.com/sajp/2016/01/powering-your-amazon-ecs-clusters-with-spot-fleet.html https://aws.amazon.com/jp/blogs/compute/dynamic-scaling-with-ec2-spot-fleet/ http://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/cloudwatch_alarm_autoscaling.html

Auto Scaling と Spot Fleetは両方セットで運用することになりそう。

selmertsx commented 7 years ago

最初は AutoScalingまで対応はしない。

http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-spotfleet.html

selmertsx commented 7 years ago

SpotFleetの設定について

方針

設定内容

AllocationStrategy: lowestPrice #defaultなので指定しなくてよい
ExcessCapacityTerminationPolicy: noTermination 
IamFleetRole: REVIEEE_FLEET_ROLE
LaunchSpecifications:
  - ImageId: ami-c393d6a4
    InstanceType: m4.large
    KeyName: REVIEEE_KEY
    Placement:
      - AvailabilityZone: ap-northeast-1a
    SecurityGroups: 
      - GroupId: REVIEEE_EC2_GROUP
    IamInstanceProfile: 
      - Arn: REVIEEE_INSTANCE_PROFILE_ARN
    SpotPrice: 0.139
    SubnetId: REVIEEE_SUBNET_ID
    UserData: "echo ECS_CLUSTER=do-review-apps >> /etc/ecs/ecs.config"
SpotPrice: 0.139
TargetCapacity: INSTANCE_CAPACITY

設定理由

SpotFleet Request Config

selmertsx commented 7 years ago

参考資料

SpotFleetのサンプル設定: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-spotfleet.html#d0e60905

SpotFleet設定サンプルその2: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet-examples.html#fleet-config1

SpotFleetRequestConfigDataのプロパティ説明 http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata.html

SpotFleetRequest全体 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-spotfleet.html

ECS用のAMI http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html

selmertsx commented 7 years ago

使う APIはコレ

https://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#request_spot_fleet-instance_method

selmertsx commented 7 years ago

IAMの設定

http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/spot-fleet-requests.html#spot-fleet-iam-users