下班后EcsService不稳定 [英] EcsService did not stabilize after hours

查看:76
本文介绍了下班后EcsService不稳定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从头开始编写了一个cloudformation JSON文件,但是我无法部署堆栈,而且我也没有AWS的任何相关信息……

I have written a cloudformation JSON file from scratch, but i can't deploy the stack and i don't have any information from AWS about why...

它在服务 CREATE_IN_PROGRESS 停留了4/5小时,然后它说服务没有稳定,并且

It gets stuck at the service CREATE_IN_PROGRESS for 4/5 hours, then it says that the service did not stabilize and rollback.

当我检查集群时,它说它是活动的,并且从AWS仪表板看一切都很好。

When i check the cluster, it says it is "active" and everything looks fine from the AWS dashboard.

我想容器遇到了问题,或者运行状况检查出了点问题,但是我没有从cloudformation中获取任何信息,有没有办法获取更多关于这4 / 5小时?

I guess the container meet an issue, or maybe something wrong with the health check, but i don't get any information from cloudformation, is there a way to get more logs about what it is going on during these 4/5 hours ?

这是我完整的JSON:

Here is my full JSON:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "test",
  "Resources": {
    "InstanceSecurityGroupOpenWeb": {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupName" : "test-open-web",
        "GroupDescription" : "Allow http to client host",
        "VpcId" : "vpc-89a8cfef",
        "SecurityGroupIngress" : [{
          "IpProtocol" : "tcp",
          "FromPort" : "80",
          "ToPort" : "80",
          "CidrIp" : "0.0.0.0/0"
        }],
        "SecurityGroupEgress" : [{
          "IpProtocol" : "tcp",
          "FromPort" : "80",
          "ToPort" : "80",
          "CidrIp" : "0.0.0.0/0"
        }]
      }
    },

    "InstanceSecurityGroupOpenFull": {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupName" : "test-open-full",
        "GroupDescription" : "Allow http to client host",
        "VpcId" : "vpc-89a8cfef",
        "SecurityGroupIngress" : [{
          "IpProtocol" : "tcp",
          "FromPort" : "0",
          "ToPort" : "65535",
          "CidrIp" : "0.0.0.0/0"
        }],
        "SecurityGroupEgress" : [{
          "IpProtocol" : "tcp",
          "FromPort" : "80",
          "ToPort" : "80",
          "CidrIp" : "0.0.0.0/0"
        }]
      }
    },

    "LoadBalancer" : {
      "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
      "DependsOn": [
        "InstanceSecurityGroupOpenWeb",
        "InstanceSecurityGroupOpenFull"
      ],
      "Properties": {
        "Name": "testalb",
        "Scheme" : "internal",
        "Subnets" : [
          "subnet-aaaaaaaa",
          "subnet-bbbbbbbb",
          "subnet-cccccccc"
        ],
        "LoadBalancerAttributes" : [
          { "Key" : "idle_timeout.timeout_seconds", "Value" : "50" }
        ],
        "SecurityGroups": [
          { "Ref": "InstanceSecurityGroupOpenWeb" },
          { "Ref" : "InstanceSecurityGroupOpenFull" }
        ]
      }
    },

    "TargetGroup" : {
      "Type" : "AWS::ElasticLoadBalancingV2::TargetGroup",
      "DependsOn": [
        "LoadBalancer"
      ],
      "Properties" : {
        "Name": "web",
        "Port": 3000,
        "TargetType": "ip",
        "Protocol": "HTTP",
        "HealthCheckIntervalSeconds": 30,
        "HealthCheckProtocol": "HTTP",
        "HealthCheckTimeoutSeconds": 10,
        "HealthyThresholdCount": 4,
        "Matcher" : {
          "HttpCode" : "200"
        },
        "TargetGroupAttributes": [{
          "Key": "deregistration_delay.timeout_seconds",
          "Value": "20"
        }],
        "UnhealthyThresholdCount": 3,
        "VpcId": "vpc-aaaaaaaa"
      }
    },

    "LoadBalancerListener": {
      "Type": "AWS::ElasticLoadBalancingV2::Listener",
      "DependsOn": [
        "TargetGroup"
      ],
      "Properties": {
        "DefaultActions": [{
          "Type": "forward",
          "TargetGroupArn": {
            "Ref": "TargetGroup"
          }
        }],
        "LoadBalancerArn": {
          "Ref": "LoadBalancer"
        },
        "Port": 80,
        "Protocol": "HTTP"
      }
    },

    "EcsCluster": {
      "Type": "AWS::ECS::Cluster",
      "DependsOn": [
        "LoadBalancerListener"
      ],
      "Properties": {
        "ClusterName": "test"
      }
    },

    "EcsTaskRole": {
      "Type":"AWS::IAM::Role",
      "Properties":{
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Effect":"Allow",
              "Principal": {
                "Service": [
                  "ecs.amazonaws.com"
                ]
              },
              "Action": [
                "sts:AssumeRole"
              ]
            }
          ]
        },
        "Path":"/",
        "Policies": [
          {
            "PolicyName": "ecs-task",
            "PolicyDocument": {
              "Statement": [
                {
                  "Effect": "Allow",
                  "Action": [
                    "ecr:**",
                  ],
                  "Resource": "*"
                }
              ]
            }
          }
        ]
      }
    },

    "WebServerTaskDefinition": {
      "Type": "AWS::ECS::TaskDefinition",
      "DependsOn": [
        "EcsCluster",
        "EcsTaskRole"
      ],
      "Properties": {
        "ExecutionRoleArn": {
          "Ref": "EcsTaskRole"
        },
        "RequiresCompatibilities": [
          "FARGATE"
        ],
        "NetworkMode": "awsvpc",
        "Cpu": "1024",
        "Memory": "2048",
        "ContainerDefinitions": [
        {
          "Name": "test-web",
          "Image": "xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/test-web:latest",
          "Cpu": "1024",
          "Memory": "2048",
          "PortMappings": [
            {
              "ContainerPort": "80",
              "HostPort": "80"
            }
          ],
          "Essential": "true"
        }]
      }
    },

    "EcsService": {
      "Type": "AWS::ECS::Service",
      "DependsOn": [
        "WebServerTaskDefinition"
      ],
      "Properties": {
        "Cluster": {
          "Ref": "EcsCluster"
        },
        "DesiredCount": "1",
        "DeploymentConfiguration": {
          "MaximumPercent": 100,
          "MinimumHealthyPercent": 0
        },
        "LoadBalancers": [
          {
            "ContainerName": "test-web",
            "ContainerPort": "80",
            "TargetGroupArn": {
              "Ref": "TargetGroup"
            }
          }
        ],
        "NetworkConfiguration": {
          "AwsvpcConfiguration": {
            "AssignPublicIp": "DISABLED",
            "SecurityGroups": [
              { "Ref": "InstanceSecurityGroupOpenWeb" },
              { "Ref": "InstanceSecurityGroupOpenFull" }
            ],
            "Subnets": [
              "subnet-aaaaaaaa",
              "subnet-bbbbbbbb",
              "subnet-cccccccc"
            ]
          }
        },
        "TaskDefinition": {
          "Ref": "WebServerTaskDefinition"
        }
      }
    }

  }
}


推荐答案

转到ECS ho mepage,找到您的群集-EcsCluster

Go to your ECS homepage , locate your cluster - EcsCluster

在仪表板类型的页面上,您将看到Service和Active / Pending Tasks。

On a dashboard kind of page , you will see Service and Active/Pending Tasks.

如果您在EcsCluster中走得更远

If you go further down inside EcsCluster


  • 在服务选项卡上,单击EcsService

  • 转到表中的任务标签,您将看到任务状态正在运行/已停止

  • 单击已停止

您应该能够看到它停止的原因。

You should be able to see reason why it is stopped.

这篇关于下班后EcsService不稳定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆