AWS EC2 映像生成器在构建映像时“没有剩余空间”

问题描述 投票:0回答:2

我正在使用 AWS Image Builder Pipeline 部署 EC2 AMI。然而,当我的 AMI 正在构建时,我从应该启动 AMI 的构建实例 EC2(由 Image Builder 创建)中收到以下错误:

标准错误:

焦油: splunk-soar /usr/python39/lib64/python3.9/config-3.9-x86_64-linux-gnu/makesetup: 无法打开:设备上没有剩余空间

焦油: splunk-soar/usr/python39/lib64/python3.9/config-3.9-x86_64-linux-gnu/python-config.py: 无法打开:设备上没有剩余空间

TOE 已完成执行但失败 - 写入 /var/lib/amazon/toe/TOE_2023-07-31_13-33-45_UTC-0_dfb87270-2fa6-11ee-a43c-0af2ba430d71/detailedoutput.json:设备上没有剩余空间。

我怀疑问题在于我如何在下面的 return_my_component_doc() 中附加我的 EBS 卷。

这是我的图像配方:

    my_image_version = "1.0.9" 
    
    my_component = imagebuilder.CfnComponent(self, "myComponent",
        name="My-Image-Component",
        platform="Linux",
        version=my_image_version,  # ie: "1.0.3",
        description="Downloads, installs and configures on Amazon Linux",
        supported_os_versions=["Amazon Linux 2"],
        data= return_my_component_doc():
    )
    
    my_image_recipe = imagebuilder.CfnImageRecipe(self, ",myImageRecipe",
        components=[{"componentArn": my_component.attr_arn}],
        name="My-Image-Recipe",
        # Amazon Linux2 X86 64bit Kernel 5.10
        parent_image="ami-076bca9dd71a9a5670",
        version=my_image_version,  # ie: "1.0.3",
        working_directory="/tmp",
    
        # EBS Volume that I want to use for spinning up the AMI.
        block_device_mappings=[imagebuilder.CfnImageRecipe.InstanceBlockDeviceMappingProperty(
                device_name="/dev/sde",
                ebs=imagebuilder.CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty(
                delete_on_termination=False,
                encrypted=False,
                iops=3000,
                throughput=125,
                volume_size=50,
                volume_type="gp3"
            )
        )]
    )
    
    my_image_pipeline = imagebuilder.CfnImagePipeline(self, "MyImagePipeline",
        infrastructure_configuration_arn=my_infrastructure_configuration.attr_arn,
        distribution_configuration_arn=my_distribution_configuration.attr_arn,
        name="My AMI Deployment Pipeline",
        image_recipe_arn = my_image_recipe.attr_arn,
    )

这是我的自定义组件附加 EBS 的数据。

        def return_my_component_doc():
            my_component_doc = f'''
            name: MyDeploymentDocument_A
            description: This is document for downloading, installing and deploying.
            schemaVersion: 1.0
            phases:
              - name: build
                steps:
                  - name: MountVolume
                    action: ExecuteBash
                    inputs:
                      commands:
                        - sudo mkfs -t xfs /dev/sde
                        - sudo mkdir /data
                        - sudo mount /dev/sde /data
            ‘’’  
            return my_component_doc

屏幕截图显示了创建 AMI 的 ImageBuilder 所配置的 EC2 内部的磁盘使用情况。它表明 ImageBuilder 未使用 50GB EBS 卷。 enter image description here

enter image description here

当我在应该启动 AMI 的构建实例 EC2 内进行 ssh 时,它看起来只写入默认的 8GB EBS 卷,而不是我在上面创建并附加的 50GB EBS 卷。我想使用更大的 EBS 卷来启动 AMI。

如何解决此错误?我希望我的 EC2 Image Builder Pipeline 在创建 AMI 时使用更大的块存储。

linux amazon-web-services amazon-ec2 aws-cdk amazon-ami
2个回答
0
投票

看起来您已将附加卷安装到

/data
,但设备上没有剩余空间发生在
/var
下方。

根据您使用的父映像,您也可以增加根卷。为此,请使用相同的设备名称(请参阅 https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html)并使用大于 8 的大小覆盖它。


0
投票

在下面的 Medium 帖子中,他们使用 Terraform 从 EC2 Image Builder 自动创建 AMI。这可能对您有用,因为他们在变量中分配卷大小https://medium.com/@joserobertonava/configuring-ec2-image-builder-with-terraform-and-automating-the-creation-of-a -new-ami-with-linux-0bf8895df5ce

© www.soinside.com 2019 - 2024. All rights reserved.