2016-12-07 59 views
0

我按照步驟在Ubuntu 16上安裝ECS客戶端,但是當我嘗試運行ECS容器代理時,它不斷重啓,當我查看日誌時亞馬遜ECS「引用的羣集不活動」

2016-12-07T06:01:39Z [INFO] Starting Agent: Amazon ECS Agent - v1.13.1 (efe53c6) 
2016-12-07T06:01:39Z [INFO] Loading configuration 
2016-12-07T06:01:39Z [INFO] Checkpointing is enabled. Attempting to load state 
2016-12-07T06:01:39Z [INFO] Loading state! module="statemanager" 
2016-12-07T06:01:39Z [INFO] Event stream ContainerChange start listening... 
2016-12-07T06:01:39Z [INFO] Detected Docker versions [1.17 1.18 1.19 1.20 1.21 1.22 1.23] 
2016-12-07T06:01:39Z [INFO] Registering Instance with ECS 
2016-12-07T06:01:39Z [ERROR] Could not register module="api client" err="ClientException: The referenced cluster was inactive. 
    status code: 400, request id: 9eaa4124-bc42-11e6-9cf1-7559dea2bdf8" 
2016-12-07T06:01:39Z [ERROR] Error registering: ClientException: The referenced cluster was inactive. 
    status code: 400, request id: 9eaa4124-bc42-11e6-9cf1-7559dea2bdf8 

我沒有找到對谷歌這個錯誤的引用,我不知道什麼是錯的......

我需要在ECS儀表盤創建羣集名稱? 我有附加器的容器作用,我的EC2實例,它允許創建集羣,所以我不認爲這個問題來自於這裏...

我的搬運工運行配置

sudo docker run --name ecs-agent \ 
--detach=true \ 
--restart=on-failure:10 \ 
--volume=/var/run/docker.sock:/var/run/docker.sock \ 
--volume=/var/log/ecs/:/log \ 
--volume=/var/lib/ecs/data:/data \ 
--net=host \ 
--env=ECS_LOGFILE=/var/log/ecs-agent.log \ 
--env=ECS_LOGLEVEL=info \ 
--env=ECS_DATADIR=/data \ 
--env=ECS_CLUSTER=my-cluster \ 
--env=ECS_ENABLE_TASK_IAM_ROLE=true \ 
--env=ECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST=true \ 
amazon/amazon-ecs-agent:latest 

回答

2

您需要調用aws ecs create-cluster --region $REGION --cluster my-cluster,通過SDK調用CreateCluster API,或者在控制檯中創建它。 ECS代理將僅自動創建名爲default的集羣,並且僅在未指定ECS_CLUSTER時纔會創建。

+0

謝謝!我沒有意識到'AmazonEC2ContainerServiceRole'沒有包含創建負載平衡器的授權。但是你確定如果給予適當的權限,集羣不會自動創建嗎? –

+1

是的,邏輯是[here](https://github.com/aws/amazon-ecs-agent/blob/v1.13.1/agent/api/ecsclient/client.go#L101-L120);它只創建'default',並且只有當'ECS_CLUSTER'沒有被指定時(我寫了一些這樣的代碼)。 –