11

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
user_dev
  • 1,357
  • 3
  • 20
  • 46

3 Answers3

6

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

Adi Dembak
  • 2,433
  • 2
  • 18
  • 26
  • Hey Adi, I saw this already but not sure I understand how to use this. For example, I need to define allocate ebs volume size of more than 100GB. Gow do I do that? – user_dev May 29 '20 at 20:56
  • 4
    There is some preparation work to be done with EFS. Check out this tutorial, for example: https://medium.com/@cmani/deploying-wordpress-on-aws-fargate-with-amazon-efs-file-system-eb7a36c22465 – Adi Dembak May 29 '20 at 21:09
  • 7
    @user_dev EBS is not supported by Fargate at all. If you need more than the 20GB ephemeral storage provided, you have to use EFS. – Mark B May 29 '20 at 21:37
  • Note that disk IO on EFS is dependent on the size of the EBS volume and is very slow. We tried this approach and had to move off of fargate onto EC2 to use EBS to get the IO speeds we needed. – gposton Oct 01 '21 at 20:31
5

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
}
ahj
  • 745
  • 1
  • 6
  • 13
  • Can you please show where in the Task Definition you define that? – MarkL Jul 15 '21 at 17:40
  • try `aws ecs register-task-definition --generate-cli-skeleton` – ahj Jul 16 '21 at 19:45
  • That is a handy command, thanks! Unfortunately, I did not see the "ephemeralStorage" option in my output. I double checked my version and it turns out the latest apt package was 1.19.1 and the feature was introduced later. I manually installed and now I see it. Thanks! – MarkL Jul 28 '21 at 03:37
  • This feature seems to no longer exist? Running generate-cli-skeleton on v2.1.32 of the awscli results in a structure with no ephemeralStorage. Has it been removed so quickly? – ndtreviv Oct 04 '21 at 13:56
0

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}
)
OES
  • 35
  • 1
  • 6