簡體   English   中英

AWS CodeDeploy 部署在事件 BlockTraffic 中失敗

[英]AWS CodeDeploy deployment failed at event BlockTraffic

我正在嘗試使用 ELB 后面的 EC2 設置從 GitHub 到 AWS 的自動部署。

遵循教程:使用 AWS CodeDeploy 從 GitHub 部署應用程序后,我的部署在 BlockTraffic 事件中失敗,嘗試了一個小時(上次 1 小時 2 分鍾),錯誤代碼為ScriptFailed 我不確定如何解決問題/在哪里查看。

ELB target group target health status: healthy

健康檢查配置:

Healthy threshold: 2 Unhealthy threshold: 2 Timeout: 5 Interval: 10 Success codes: 200

如果您的 Code Deploy 角色在 ELB 后面,請確保您的 Code Deploy 角色有足夠的權限來注冊和取消注冊實例。

可能需要以下權限。

"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DescribeInstanceHealth",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
"elasticloadbalancing:DescribeTargetGroups",
"elasticloadbalancing:DescribeTargetHealth",
"elasticloadbalancing:RegisterTargets",
"elasticloadbalancing:DeregisterTargets"

有一個 AWSCodeDeployRole 策略,可以很容易地涵蓋使用 codedeploy 所需的權限

我遇到了同樣的問題,我意識到在部署組中,我沒有標記目標組的實例 ID,我正在對其進行健康檢查以查看目標組是否健康。 因此部署組知道目標組,它必須處理流量。

不要在管道的代碼部署部署組上啟用負載均衡器,您將擺脫 BlockTraffic 和 AllowTraffic 步驟。

截屏

我遇到的問題是,對於 ELB,如果端口不是預期的端口,代碼部署的 BlockTraffic 將不知道如何從目標組中注銷實例。

在我的示例中,我讓我的 HTTPS ELB 通過 HTTP 與我的每個目標組上的端口 3000 進行通信。 我使用本指南找到了具體的根本原因: https://aws.amazon.com/premiumsupport/knowledge-center/codedeploy-failed-ec2-deployment/

它給出了以下 output,它使用端口 3000 而不是預期的端口 80 標識了我的實例。

During BlockTraffic, Codedeploy service invoke the Loadbalancer to de-register the instance from the target group before start installing the application revision
DeregisterTargets API call can be noticed in cloudtrail logs during BlockTraffic lifecycle hook
Currently Codedeploy does not support the case when the target group have a different port than the port used to register the instance.
** DeregisterTargets API will not be able to deregister the instance if the port configured in the Target group is different
You need to make sure that both the target group and the instance are configured to use the same port.
BlockTraffic depends mainly on the de-registration delay on the target group or connection draining on Classic LB. To speed up this step, the de-registration delay /connection draining value can be reduced to a reasonable value.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM