简体   繁体   中英

How can I increase the disk space in AWS Fargate container?

I am deploying containers via AWS Fargate but I am running into "No Space left on device" . Is there a way I can specify the volume size in task_definitions:

task_size:
    mem_limit: 2GB
    cpu_limit: 256

As of Fargate platform 1.4, released on 04/2020, ephemeral storage is now 20 GB, instead of 10 GB. Additionally, you can now mount persistent EFS storage volumes in Fargate tasks.

For example:

{
    "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"
                }
            }
        }
    ]
}

Taken from: efs-volumes in Fargate

You can now increase your fargate ephemeral storage to 200GB in task definition. Therefore with this there is no need to attach the volume unless you need a storage of larger than 200GB.

"ephemeralStorage": {
   "sizeInGiB": 200
}

As mentioned by ahj, you can increase the Fargate ephemeral storage in task definition. Example provided in the official docs here .

It's quite disappointing that, at the time of writing this answer, the ephemeralStorage parameter is not configurable from the AWS console. The docs mention that it can be edited via AWS Copilot CLI, CloudFormation, AWS SDK, and AWS CLI.

A common use case is when someone wants to create a new revision of a task definition.

Here's an example of creating a new task definition from a previous revision, with the single difference that now you're setting the ephemeralStorage parameter with Python boto3 (docs for using ECS with boto3 here ).

import boto3

client = boto3.client('ecs')
response = client.describe_task_definition(taskDefinition='your-task-definition')
task_definition = response['taskDefinition']
# task_definition is a dictionary, you can print it, or save it in a json file,
# or just view it if you're running from a Python console and you have a variable explorer

# now, create a new revision
client.register_task_definition(
    # look at your task_definition dict to fill the arguments and add:
    ephemeralStorage={"sizeInGiB": 200}
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM