我正在尝试在AWS ECS中使用Python3
部署CodeDeploy
应用程序。
此处的问题是,尽管由代码部署创建了实例,并且ECS在此处部署了任务,但流量重定向无法正常工作。
我有以下ecs服务定义:
resource "aws_ecs_service" "service" {
name = "service"
cluster = aws_ecs_cluster.cluster.name
task_definition = aws_ecs_task_definition.task_definition.arn
deployment_minimum_healthy_percent = 0
deployment_maximum_percent = 100
scheduling_strategy = "DAEMON"
load_balancer {
target_group_arn = var.target_group_arn[0]
container_name = var.namespace
container_port = 8080
}
launch_type = "EC2"
depends_on = [aws_ecs_task_definition.task_definition]
}
部署组为
resource "aws_codedeploy_deployment_group" "group" {
app_name = aws_codedeploy_app.app.name
deployment_group_name = aws_codedeploy_app.app.name
service_role_arn = aws_iam_role.codedeploy.arn
autoscaling_groups = ["my-autoscaling-group"]
deployment_config_name = "CodeDeployDefault.ECSAllAtOnce"
ec2_tag_set {
ec2_tag_filter {
key = "deploy"
type = "KEY_AND_VALUE"
value = "tf"
}
}
deployment_style {
deployment_option = "WITH_TRAFFIC_CONTROL"
deployment_type = "BLUE_GREEN"
}
auto_rollback_configuration {
enabled = true
events = ["DEPLOYMENT_FAILURE"]
}
load_balancer_info {
target_group_info {
name = "my-balancer"
}
}
blue_green_deployment_config {
deployment_ready_option {
action_on_timeout = "CONTINUE_DEPLOYMENT"
}
green_fleet_provisioning_option {
action = "COPY_AUTO_SCALING_GROUP"
}
terminate_blue_instances_on_deployment_success {
action = "TERMINATE"
termination_wait_time_in_minutes = 0
}
}
}
任务定义
[
{
"name": "name",
"image": "my-image",
"cpu": 7,
"dnsSearchDomains": null,
"logConfiguration": null,
"entryPoint": null,
"portMappings": [
{
"hostPort": 8081,
"protocol": "tcp",
"containerPort": 8080
},
{
"hostPort": 8793,
"protocol": "tcp",
"containerPort": 8793
}
],
"command": null,
"linuxParameters": null,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [
{
"readOnly": null,
"containerPath": "/usr/local/airflow/dags",
"sourceVolume": "dags"
},
{
"readOnly": null,
"containerPath": "/usr/local/airflow/logs",
"sourceVolume": "logs"
},
{
"readOnly": null,
"containerPath": "/helper",
"sourceVolume": "helper"
},
],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memoryReservation": 128,
"volumesFrom": [],
"stopTimeout": null,
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null
}
]