简体   繁体   English

带有自动伸缩启动模板的AWS CodeDeploy与竞价型和按需实例混合

[英]AWS CodeDeploy with Autoscaling Launch Templates with Spot and On-Demand Instances mix

It is possible to configure an autoscaling group to use Launch Template instead of Launch Configuration. 可以将自动缩放组配置为使用启动模板而不是启动配置。 I want to use it because when I configure an autoscaling group using Launch Configuration I can not set mixed instances policy (ondemand + spot instances). 我想使用它,因为当我使用启动配置配置自动伸缩组时,无法设置混合实例策略(按需+竞价型实例)。

I have created launch template (name 'test') with such configuration: 我已经使用以下配置创建了启动模板(名称为“ test”):

    AMI Ubuntu 16, 
    some security groups and IAM Role with EC2, AutoScaling and CodeDeploy full access 
    and all other settings in default *Not specified* state.

    Launch Template ID lt-0e1111
    Default Version Number 1
    Launch Template Name test
    Owner arn:aws:iam::11111111:user/itsp
    Version  1 (Default)
    Name  test
    Created by arn:aws:iam::179961111910:user/itsp
    Description Not specified
    Date Created February 8, 2019 at 12:47:54 AM UTC+3
    AMI ID ami-0bf1924ed30c48a6a
    Availability Zone Not specified
    Security Groups Not specified
    Instance Type t2.nano
    Key pair name itsp
    Security Group Ids sg-07e746cf0e4935b84,sg-0a45f7e6ac321614d,sg-27bf6d4b

    Advanced Details:
    Purchasing option Not specified
    Spot request type Not specified
    Spot interruption behavior Not specified
    IAM Instance Profile Not specified
    Stop - Hibernate behavior Not specified
    Monitoring Not specified
    EBS-optimized instance Not specified
    Tenancy Host ID Not specified
    RAM Disk ID Not specified
    User Data Not specified
    Elastic Inference Accelerator Not specified
    Maximum Spot price Not specified
    Spot expiry date -
    Spot block duration Not specified
    Shutdown behavior Not specified
    Termination Protection Not specified
    Placement Group Name Not specified
    Tenancy Not specified
    Tenancy Affinity Not specified
    Kernel ID Not specified
    Elastic Graphics Not specified

Then I am creating an AutoScaling group with that launch template. 然后,我使用该启动模板创建一个AutoScaling组。 Here is my autoscaling group configuration: 这是我的自动伸缩组配置:

Launch Template test
Launch Template Version 1
Launch Template Description -
Instance Types -
Spot Diversity 0
Optional On-Demand Base 0
On-Demand Percentage 0%
Desired Capacity 1 
Min 1 
Max 1
Availability Zone(s) eu-central-1a
Subnet(s) subnet-53075e38
Classic Load Balancers -
Target Groups -
Health Check Type EC2
Health Check Grace Period 300
Instance Protection - 
Termination Policies Default
Suspended Processes -
Placement Groups -
Default Cooldown 300
Enabled Metrics -
Creation Time Fri Feb 08 00:50:16 GMT+300 2019
Service-Linked Role arn:aws:iam::11111111111:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling

Such configuration appears to be set when I choose 当我选择时,似乎已设置了这种配置

*Fleet Composition - Adhere to the launch template
The launch template determines the instance type and purchase option (On-Demand or Spot).* 

option and my lauch template configuration is described above. 选项和我的lauch模板配置如上所述。

So there are no spots in my autoscaling group. 因此,我的自动缩放组中没有任何位置。

Then I configure a CodeDeploy application 'Application' and DeploymentGroup 'DG_TEST' inside of it with such configuration: 然后,使用以下配置在其中配置CodeDeploy应用程序“应用程序”和DeploymentGroup“ DG_TEST”:

Deployment type Blue/green
Service role ARN arn:aws:iam::11111111111111:role/CodeDeployRole
Deployment configuration CodeDeployDefault.AllAtOnce
Rollback enabled -
Environment configuration: Amazon EC2 Auto Scaling groups -> Name 'test'

Ok, after everything is set up I set desired instances count to 1 in my Autoscaling group and new on-demand instance spawns in my 'test' group. 好的,一切设置完成后,我在Autoscaling组中将所需实例数设置为1,在“ test”组中生成了新的按需实例。

I am now starting a blue-green deployment with AWS CLI command: 我现在正在使用AWS CLI命令开始蓝绿色部署:

aws deploy create-deployment --application-name Application --s3-location bucket=codedeploybucket,key=application,bundleType=zip --deployment-group-name DG_TEST

And I can see new autoscaling group with same lauch template appears in my green fleet. 我可以看到带有相同模板的新自动缩放组出现在我的绿色车队中。

So we just checked all our services are working as expected. 因此,我们只是检查了我们所有的服务是否按预期工作。


Now I want to tweak my autoscaling group configuration a little to mix ondemand and spot instances in it: 现在,我想稍微调整一下我的自动伸缩组配置,以在其中混合按需实例。

Fleet Composition - Combine purchase options and instances
Choose a mix of On-Demand Instances and Spot Instances and multiple instance types. Spot Instances are automatically launched at the lowest price available.
Instance Types:
t2.nano (1vCPUs, 0.5GiB)
t2.small (1vCPUs, 2GiB)
t2.micro (1vCPUs, 1GiB)
Maximum Spot Price - Use default (recommended)
Spot Allocation Strategy - Diversify Spot Instances across your 2 lowest priced instance types per Availability Zone
Optional On-Demand Base - Designate the first 0 instances as On-Demand
On-Demand Percentage 50% On-Demand and 50% Spot
Desired Capacity 1
Min 1
Max 1

I save it and try same AWS CLI command 我将其保存并尝试相同的AWS CLI命令

aws deploy create-deployment --application-name Application --s3-location bucket=codedeploybucket,key=application,bundleType=zip --deployment-group-name DG_TEST

And now I have my deployment failed with such comment: 现在,我的部署失败,出现以下注释:

The following validation error occurred: Valid requests must contain either LaunchTemplate, LaunchConfigurationName, InstanceId or MixedInstancesPolicy parameter. (Service: AmazonAutoScaling; Status Code: 400; Error Code: ValidationError; Request ID: 11111114-2b2b-11e9-93b7-11111111111)

Another strange thing is that if I configure my Launch Templae to use spots only: 另一个奇怪的事情是,如果我将启动模板配置为仅使用斑点:

Launch Template ID lt-00dc4c187d1111159
Default Version Number   1
Launch Template Name test2
Owner
arn:aws:iam::179961111910:user/itsp
Version     1 (Default)
Name  test2
Created by  arn:aws:iam::179961111910:user/itsp
Description Not specified
Date Created    February 8, 2019 at 1:14:13 AM UTC+3
AMI ID    ami-0bf1924ed30c48a6a
Availability Zone    Not specified
Security Groups   Not specified
Instance Type    t2.micro
Key pair name    itsp
Security Group Ids    sg-0a45f7e6ac321614d,sg-07e746cf0e4935b84,sg-27bf6d4b

Advanced details
Purchasing option    spot
Spot request type    one-time
Spot interruption behavior    Not specified
IAM Instance Profile    CodeDeployRole (arn:aws:iam::1111111111:instance-profile/CodeDeployRole)
Stop - Hibernate behavior    Not specified
Monitoring    Not specified
EBS-optimized instance   Not specified
Tenancy Host ID    Not specified
RAM Disk ID    Not specified
User Data    Not specified
Elastic Inference Accelerator    Not specified
Maximum Spot price    Not specified
Spot expiry date    -
Spot block duration    Not specified
Shutdown behavior    Not specified
Termination Protection    Not specified
Placement Group Name    Not specified
Tenancy    Not specified
Tenancy Affinity    Not specified
Kernel ID    Not specified
Elastic Graphics    Not specified

and use that option in my autoscaling group: 并在我的自动缩放组中使用该选项:

*Fleet Composition - Adhere to the launch template
    The launch template determines the instance type and purchase option (On-Demand or Spot).* 

Then after same deployment command I receive another error in CodeDeploy (failed deployment reason): 然后在执行相同的部署命令后,我在CodeDeploy中收到另一个错误(失败的部署原因):

The IAM role arn:aws:iam::179966034910:role/CodeDeployRole does not give you permission to perform operations in the following AWS service: AmazonAutoScaling. Contact your AWS administrator if you need help. If you are an AWS administrator, you can grant permissions to your users or groups by creating IAM policies.

And that is definitely not the case because my role for CodeDeploy have full EC2, Autoscaling and CodeDeploy access. 绝对不是这样,因为我在CodeDeploy的角色具有完全的EC2,Autoscaling和CodeDeploy访问权限。


Am I doing something wrong or that are bugs? 我是在做错什么还是虫子? How can I configure mixed autoscaling group (ondemand+spot instances) with codedeploy using launch templates? 如何使用启动模板通过codedeploy配置混合自动缩放组(按需实例)? Thanks in advance! 提前致谢!

I faced a similar issue when working with CodeDeploy and LaunchTemplates . 使用CodeDeployLaunchTemplates时,我遇到了类似的问题。
It looks like LaunchTemplates are still not supported by CodeDeploy. 看起来CodeDeploy仍然不支持LaunchTemplates。

We have to stick to LaunchConfigurations . 我们必须坚持使用LaunchConfigurations They still don't support versioning, but for the most part, they are pretty much the same :/ 他们仍然不支持版本控制,但是在大多数情况下,它们几乎是相同的:/

I could't find where AWS has documented that little incompatibility issue when migrating LaunchConfigurations to LaunchTemplates... but could find here more info. 在将LaunchConfigurations迁移到LaunchTemplates时,我找不到AWS在哪里记录了这个很小的不兼容问题...但是可以在这里找到更多信息。

Sheers! SHEERS!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果没有可用的现货实例,具有 MixedInstancesPolicy 的 AWS Autoscaling 组是否会启动按需实例? - Will AWS Autoscaling group with MixedInstancesPolicy launch On-Demand instance if no spot instances available? 使用 Terraform aws_spot_fleet_request 资源使用 launch_template 设置 AWS 按需实例? - Setting AWS on-demand instances using Terraform aws_spot_fleet_request resource using a launch_template? AWS 自动扩展和 Spot 实例 - AWS autoscaling and spot instances AWS EC2中的预留实例是否具有比按需实例或竞价型实例更好的性能? - Do Reserved Instances in AWS EC2 Have Better Performance Than On-Demand or Spot Instances? 如果 Spot 实例在 AWS 中不可用,我可以获取按需 EC2 实例吗 - Can I get the on-demand EC2 instances if spot instances are not available in AWS 如何配置 aws EKS 集群以同时使用现货和按需实例 - How to configure aws EKS Cluster to use both spot and on-demand instances 当Autoscaling Group设置为0个实例时,AWS Codedeploy - AWS Codedeploy when Autoscaling Group set to 0 instances AWS EKS - 使用具有故障转移到按需的现场节点 - AWS EKS - use spot nodes with failover to on-demand 替代AWS上的专色实例的内置自动缩放组 - Alternative for built-in autoscaling groups for spot instances on AWS 将普通/按需实例转换为 Spot? - Converting normal/on-demand instance to Spot?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM