我计划迁移到 Fargate 以实现自动扩展。我已经为当前处于活动状态的暂存和生产环境制定了任务定义。我认为有两种方法可以迁移到 Fargate,要么创建一个新的任务定义以使用 Fargate,然后使用与我的 EC2 实例使用的配置几乎相同的配置。或者,我可以将相关的任务定义导出到 JSON 中,并将 和 的值替换requiredCompatibilities
为,compatibilites
然后EC2
就FARGATE
完成了,然后部署。不知道这样行不行?这是一个示例任务定义,我已将其修改为在上述键中使用 FARGATE。一些编辑过的数据,例如环境变量。
{
"ipcMode": null,
"executionRoleArn": null,
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/MY-PROJECT-staging",
"awslogs-region": "my-region",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": null,
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8020
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": 300,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG",
"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": {
"env": "staging"
},
"systemControls": null,
"privileged": null,
"name": "MY-PROJECT-web-stage"
}
],
"placementConstraints": [],
"memory": null,
"taskRoleArn": null,
"compatibilities": [
"FARGATE" | Earlier this was EC2
],
"taskDefinitionArn": "task-definition/MY-PROJECT-staging:10",
"family": "MY-PROJECT-staging",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
}
],
"pidMode": null,
"requiresCompatibilities": [
"FARGATE" | Earlier this was EC2
],
"networkMode": null,
"cpu": null,
"revision": 10,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}