AWS Elastic Beanstalk EFS Mount Error: unknown filesystem type 'efs'

AWS Elastic Beanstalk EFS Mount Error: unknown filesystem type 'efs'

我正在尝试使用 Dockerrun.aws.json 的任务定义将我的 EFS 安装到多 docker Elastic Beanstalk 环境。另外,我已经配置了 EFS 的安全组来接受来自 EC2(EB 环境)安全组的 NFS 流量。

但是,我遇到了错误:

ECS task stopped due to: Error response from daemon: create ecs-awseb-SeyahatciBlog-env-k3k5grsrma-2-wordpress-88eff0a5fc88f9ae7500: VolumeDriver.Create: mounting volume failed: mount: unknown filesystem type 'efs'.

我正在使用 AWS 管理控制台上传此 Dockerrun.aws.json 文件:

{
  "AWSEBDockerrunVersion": 2,
  "authentication": {
    "bucket": "seyahatci-docker",
    "key": "index.docker.io/.dockercfg"
  },
  "volumes": [
    {
      "name": "wordpress",
      "efsVolumeConfiguration": {
        "fileSystemId": "fs-d9689882",
        "rootDirectory": "/blog-web-app/wordpress",
        "transitEncryption": "ENABLED"
      }
    },
    {
      "name": "mysql-data",
      "efsVolumeConfiguration": {
        "fileSystemId": "fs-d9689882",
        "rootDirectory": "/blog-db/mysql-data",
        "transitEncryption": "ENABLED"
      }
    }
  ],
  "containerDefinitions": [
    {
      "name": "blog-web-app",
      "image": "bireysel/seyehatci-blog-web-app",
      "memory": 256,
      "essential": false,
      "portMappings": [
        {"hostPort": 80, "containerPort": 80}
      ],
      "links": ["blog-db"],
      "mountPoints": [
        {
          "sourceVolume": "wordpress",
          "containerPath": "/var/www/html"
        }
      ]
    },
    {
      "name": "blog-db",
      "image": "mysql:5.7",
      "hostname": "blog-db",
      "memory": 256,
      "essential": true,
      "mountPoints": [
        {
          "sourceVolume": "mysql-data",
          "containerPath": "/var/lib/mysql"
        }
      ]
    }
  ]
}

AWS 配置截图:

  1. EC2 Security Group (Automatically created by EB)
  2. EFS Security Group
  3. EFS networking

找遍全网,没有遇到这个问题的解决办法。我联系了 AWS Support。他们告诉我问题出在 Elastic Beanstalk 创建的 EC2 实例上缺少“amazon-efs-utils”扩展,然后我通过在 .ebextensions 文件夹中创建一个名为 efs.config 的文件修复了错误:

.ebextensions/efs.config

packages:
  yum:
    amazon-efs-utils: 1.2

最后,我在上传前压缩了 .ebextensions 文件夹和我的 Dockerrun.aws.json 文件,问题已经解决。

我的场景:

  • 使用 Amazon 设置一些 EC2 Linux 2 个 AMI。
  • 尝试设置 EFS

尝试挂载 EFS 驱动器时出现同样的错误。

似乎包 WAS NOT 包含在 Amazon Linux 2 AMI 中,尽管文档指定应包含它。

The amzn-efs-utils package comes preinstalled on Amazon Linux and Amazon Linux 2 Amazon Machine Images (AMIs).

https://docs.aws.amazon.com/efs/latest/ug/overview-amazon-efs-utils.html

运行 which amzn-efs-utils returns: 没有安装 amzn-efs-utils。

$ which amzn-efs-utils
/usr/bin/which: no amzn-efs-utils in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin)

修复

安装 amzn-efs-utils

sudo yum install amazon-efs-utils