amazon-web-services - AWS ECS 任务定义自动缩放

标签 amazon-web-services automation aws-cloudformation autoscaling aws-cloudformation-custom-resource

我有一个问题希望你能帮忙。 我想做 aws ecs 任务,但找不到自动缩放它的方法 它卡在256CPU和512内存上,我不想硬编码它(2G内存),因为我并不总是需要它

 Parameters:
  SubnetIds:
    Type: "List<AWS::EC2::Subnet::Id>"
    Description: Select at least two subnets in your selected VPC.

Resources:      
  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: name
      NetworkMode: awsvpc
      RequiresCompatibilities: 
        - FARGATE
      ContainerDefinitions:
        - 
          Name: "name"
          Image: "**/latest"
          Essential: true
          logConfiguration:
            logDriver: awslogs
            options:
              awslogs-group: /log/scheduledtasks
              awslogs-region: us-east-2
              awslogs-stream-prefix: log         
          Environment:
            - Name: OP_MODE
              Value: CRONJOB                
          Secrets:**                                                                                                                           
      ExecutionRoleArn: !ImportValue TaskExecutionRole  
      Cpu: 256
      Memory: 512
    
  TaskSchedule1:
    Type: AWS::Events::Rule
    Properties: 
      Description: Description
      Name: name
      ScheduleExpression: cron(5 10 * * ? *) 
      State: ENABLED
      Targets:
      - Id: id-name
        RoleArn: !ImportValue SchedulerRole
        EcsParameters:
          TaskDefinitionArn:
            Ref: TaskDefinition
          TaskCount: 1
          LaunchType: FARGATE
          NetworkConfiguration:
            AwsVpcConfiguration:
              AssignPublicIp: ENABLED
              Subnets: !Split [',', !Join [',', !Ref SubnetIds]]
        Input: '{"containerOverrides":[{"name":"a","environment":[{"name":"TARGET_JOB","value":"definition"}]}]}'
        Arn: !ImportValue Cluster
    

任何提示或资源都会很有帮助 我还在学习中,谢谢您的帮助

最佳答案

不能这样做。不是这样autoscaling of ECS服务/任务工作。您可以通过启动同一任务的多个实例来自动缩放服务,而不是通过自动增加/减少分配的 RAM 和 CPU 量。

关于amazon-web-services - AWS ECS 任务定义自动缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68282908/

相关文章:

amazon-web-services - SQS 是否会杀死具有 Thread.sleep 的长时间运行的作业?

java - 构建后,使用Gradle自动将属性文件处理到相同目录

swift - XCTest() 获取 XCUIElement 的父级

amazon-web-services - Cloudformation YAML : expected type String, 找到 JSONObject

amazon-web-services - 何时使用 DhcpOptions

amazon-web-services - CloudFormation 模板 AutoScalingGroup 可用区

amazon-web-services - Terraform 可以通过remote_exec 命令设置变量吗?

python - 是否可以通过serverless.yml向PATH环境变量添加路径?

python - 使用工作层在 Elastic Beanstalk 上使用 Django 设置计划/cron 作业

Xcode Instruments 给出此错误 "Could not start script, target application is not frontmost."