[关闭]
@xtccc 2017-09-12T23:50:47.000000Z 字数 2242 阅读 1904

Spot Fleet Instance

给我写信
GitHub

此处输入图片的描述


AWS


目录:


1. 申请Spot Fleet Instance


通过AWS Client申请。

  1. $ aws ec2 request-spot-fleet --spot-fleet-request-config file://test.json --region us-west-2
  2. 返回
  3. {
  4. "SpotFleetRequestId": "sfr-6f5f82e5-3d2c-4422-81c7-xxxxx"
  5. }

其中,test.json是关于Fleet Request的配置文件,一个样例为:

  1. {
  2. "IamFleetRole": "arn:aws:iam::xxxxx:role/aws-ec2-spot-fleet-tagging-role",
  3. "AllocationStrategy": "lowestPrice",
  4. "TargetCapacity": 2,
  5. "SpotPrice": "0.1225",
  6. "ValidFrom": "2017-09-11T09:50:00Z",
  7. "ValidUntil": "2018-09-11T09:50:00Z",
  8. "TerminateInstancesWithExpiration": true,
  9. "Type": "maintain",
  10. "LaunchSpecifications": [
  11. {
  12. "ImageId": "ami-xxxxxx",
  13. "InstanceType": "m1.xlarge",
  14. "SubnetId": "subnet-xxxxx",
  15. "KeyName": "akka_oregon",
  16. "WeightedCapacity": 4,
  17. "SpotPrice": "0.0875",
  18. "IamInstanceProfile": {
  19. "Arn": "arn:aws:iam::xxxxxxxxx:instance-profile/akka-web"
  20. },
  21. "SecurityGroups": [
  22. {
  23. "GroupId": "sg-xxxxx"
  24. }
  25. ],
  26. "UserData": "bWtkaXIgdGFv",
  27. "TagSpecifications": [
  28. {
  29. "ResourceType": "instance",
  30. "Tags": [
  31. {
  32. "Key": "Name",
  33. "Value": "XiaoTao"
  34. }
  35. ]
  36. }
  37. ]
  38. },
  39. {
  40. "ImageId": "ami-yyyyy",
  41. "InstanceType": "m2.4xlarge",
  42. "SubnetId": "subnet-yyyyy",
  43. "KeyName": "akka_oregon",
  44. "WeightedCapacity": 8,
  45. "SpotPrice": "0.1225",
  46. "IamInstanceProfile": {
  47. "Arn": "arn:aws:iam::yyyyyyyy:instance-profile/akka-web"
  48. },
  49. "SecurityGroups": [
  50. {
  51. "GroupId": "sg-yyyyyy"
  52. }
  53. ],
  54. "UserData": "bWtkaXIgdGFv",
  55. "TagSpecifications": [
  56. {
  57. "ResourceType": "instance",
  58. "Tags": [
  59. {
  60. "Key": "Name",
  61. "Value": "XiaoTao"
  62. }
  63. ]
  64. }
  65. ]
  66. }
  67. ]
  68. }



2. 描述一个Fleet Request


  1. $ aws ec2 describe-spot-fleet-instances --spot-fleet-request-id sfr-6f5f82e5-3d2c-4422-xxxxx --region us-west-2
  2. 返回
  3. {
  4. "ActiveInstances": [
  5. {
  6. "InstanceId": "i-xxxxx",
  7. "InstanceType": "m1.small",
  8. "SpotInstanceRequestId": "sir-xxxx"
  9. },
  10. {
  11. "InstanceId": "i-yyyyy",
  12. "InstanceType": "m1.small",
  13. "SpotInstanceRequestId": "sir-yyyyy"
  14. }
  15. ],
  16. "SpotFleetRequestId": "sfr-6f5f82e5-3d2c-4422-xxxxx"
  17. }



3. 终止Spot Fleet Request/Instance


  1. $ aws ec2 cancel-spot-fleet-requests --spot-fleet-request-ids sfr-6f5f82e5-3d2c-4422-81c7-xxxx --terminate-instances --region us-west-2
  2. 返回
  3. {
  4. "SuccessfulFleetRequests": [
  5. {
  6. "PreviousSpotFleetRequestState": "active",
  7. "CurrentSpotFleetRequestState": "cancelled_terminating",
  8. "SpotFleetRequestId": "sfr-6f5f82e5-3d2c-4422-81c7-xxxx"
  9. }
  10. ],
  11. "UnsuccessfulFleetRequests": []
  12. }

注意,必须加上--terminate-instances,否则只是cancel spot fleet request, 正在运行的spot fleet instances不会被terminate。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注