问题描述
我正在使用集成到 CodePipeline 中的 CodeDeploy 。我正在尝试将映像从 ecr 部署到 ecs 。
I am using CodeDeploy integrated into CodePipeline. I am trying to deploy an image from ecr to ecs.
整个基础架构都是使用构建的CloudFormation 。
The whole infrastructure is built with CloudFormation.
管道部署组的模板:
ApplicationName=cls.application.ApplicationName,
DeploymentGroupName='DeploymentGroup',
DeploymentConfigName='CodeDeployDefault.ECSAllAtOnce',
ServiceRoleArn=GetAtt(cls.role, 'Arn'),
AutoRollbackConfiguration={
'enabled': True,
'events': ['DEPLOYMENT_FAILURE', 'DEPLOYMENT_STOP_ON_ALARM', 'DEPLOYMENT_STOP_ON_REQUEST']
},
DeploymentStyle={
'deploymentType': 'BLUE_GREEN',
'deploymentOption': 'WITH_TRAFFIC_CONTROL'
},
BlueGreenDeploymentConfiguration={
'terminateBlueInstancesOnDeploymentSuccess': {
'action': 'TERMINATE',
'terminationWaitTimeInMinutes': 5
},
'deploymentReadyOption': {
'actionOnTimeout': 'CONTINUE_DEPLOYMENT',
},
},
LoadBalancerInfo= <Some irrelevant config>
EcsServices=[
{
'serviceName': 'WordpressService',
'clusterName': 'WordpressCluster'
},
]
到目前为止,配置似乎非常简单。 管道本身的配置包含两个阶段:
So far - the configuration seems pretty straight-forward. The configuration for the pipeline itself contains 2 stages:
ArtifactStore=ArtifactStore(
Location='SomeS3Location',
Type='S3'
),
Name='WordpressPipeline',
RoleArn=GetAtt(cls.role, 'Arn'),
Stages=[
Stages(
Name='SourceStage',
Actions=[
Actions(
Name='SourceAction',
ActionTypeId=ActionTypeId(
Category='Source',
Owner='AWS',
Version='1',
Provider='ECR'
),
OutputArtifacts=[
OutputArtifacts(
Name='SourceOutput'
)
],
Configuration={
'RepositoryName':'SomeECR'
},
RunOrder='1'
)
]
),
Stages(
Name='DeployStage',
Actions=[
Actions(
Name='DeployAction',
ActionTypeId=ActionTypeId(
Category='Deploy',
Owner='AWS',
Version='1',
Provider='CodeDeploy'
),
InputArtifacts=[
InputArtifacts(
Name='SourceOutput'
)
],
Configuration={
'ApplicationName': 'MyApp',
'DeploymentGroupName': 'MyGroup'
},
RunOrder='1'
)
]
)
]
PS不要介意语法。我正在使用 Troposphere 创建 CloudFormation 模板。
P.S. dont mind the syntax. I am using Troposphere to create CloudFormation templates.
首先, CloudFormation 模板成功运行。
第二,从ECR采购成功。
Secondly, Sourcing from ECR succeed.
第三,部署失败,并显示以下消息:
Thirdly, deployment fails with message:
您是否知道问题出在哪里?
Do you have any idea where might be the problem?
谢谢。
推荐答案
找出问题所在。
部署提供程序是 CodeDeploy ,它对我的蓝/绿部署无效。我不得不指定 CodeDeployToECS 。另外,我必须更改所需的环境参数。这是AWS的一个不错的教程:
Found out where the issue was.The deploy provider was CodeDeploy which is not valid for my blue/green deployments. I hade to specify CodeDeployToECS instead. Also, I had to change required environment parameters. Here is a nice tutorial by AWS:https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html#tutorials-ecs-ecr-codedeploy-pipeline
这篇关于部署指定修订为空文件,但提供的修订为zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!