如何增加 AWS Fargate 容器中的磁盘空间?

use*_*dev 8 amazon-web-services amazon-ecs aws-fargate

我正在通过 AWS Fargate 部署容器,但我遇到了"No Space left on device". 有没有办法可以在 task_definitions 中指定卷大小:

task_size:
    mem_limit: 2GB
    cpu_limit: 256
Run Code Online (Sandbox Code Playgroud)

Adi*_*bak 5

自2020 年 4 月发布的Fargate平台 1.4 起,临时存储现在为 20 GB,而不是 10 GB。此外,您现在可以在Fargate任务中挂载持久性EFS存储卷。

例如:

{
    "containerDefinitions": [
        {
            "name": "container-using-efs",
            "image": "amazonlinux:2",
            "entryPoint": [
                "sh",
                "-c"
            ],
            "command": [
                "ls -la /mount/efs"
            ],
            "mountPoints": [
                {
                    "sourceVolume": "myEfsVolume",
                    "containerPath": "/mount/efs",
                    "readOnly": true
                }
            ]
        }
    ],
    "volumes": [
        {
            "name": "myEfsVolume",
            "efsVolumeConfiguration": {
                "fileSystemId": "fs-1234",
                "rootDirectory": "/path/to/my/data",
                "transitEncryption": "ENABLED",
                "transitEncryptionPort": integer,
                "authorizationConfig": {
                    "accessPointId": "fsap-1234",
                    "iam": "ENABLED"
                }
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

取自: Fargate 中的 efs-volumes

  • @user_dev Fargate 根本不支持 EBS。如果您需要超过所提供的 20GB 临时存储空间,则必须使用 EFS。 (7认同)
  • 使用 EFS 需要完成一些准备工作。查看本教程,例如:https://medium.com/@cmani/deploying-wordpress-on-aws-fargate-with-amazon-efs-file-system-eb7a36c22465 (4认同)

ahj*_*ahj 5

您现在可以在任务定义中将 Fargate 临时存储增加到 200GB。因此,除非您需要大于 200GB 的存储空间,否则无需附加卷。

"ephemeralStorage": {
   "sizeInGiB": 200
}
Run Code Online (Sandbox Code Playgroud)