Disk size is larger than image size when creating Compute Engine VM in Google Cloud Deployment Manager Template

huangapple go评论51阅读模式
英文:

Disk size is larger than image size when creating Compute Engine VM in Google Cloud Deployment Manager Template

问题

我正在使用Google Cloud Deployment Manager模板在Google Cloud中创建一个Compute Engine VM实例。然而,在部署过程中,我遇到了一个警告:“磁盘大小:'60 GB'大于镜像大小:'10 GB'。”部署成功完成,但我想了解这个警告的影响以及如何解决它。

以下是我的Deployment Manager模板代码:

def generate_config(context):
    COMPUTE_URL_BASE = "https://www.googleapis.com/compute/v1/projects"
    SOURCE_IMAGE = f"{COMPUTE_URL_BASE}/debian-cloud/global/images/family/debian-11"
    DISK_SIZE = 60
    
    VM_MACHINE_TYPE = "g1-small"
    REGION = "europe-west2-b"
    PROJECT_ID = context.env["project"]
    VPC_NETWORK = "default"
    SUBNETWORK = "default"

    VM = {
        "name": "dinesh-vm",
        "type": "compute.v1.instance",
        "properties": {
            "zone": REGION,
            "machineType": f"zones/{REGION}/machineTypes/{VM_MACHINE_TYPE}",
            "disks": [{
                "boot": True,
                "autoDelete": True,
                "initializeParams": {
                    "sourceImage": SOURCE_IMAGE,
                    "diskSizeGb": DISK_SIZE,
                },
            }],
            "networkInterfaces": [{
                "network": f"{COMPUTE_URL_BASE}/{PROJECT_ID}/global/networks/{VPC_NETWORK}",
                "subnetwork": f"{COMPUTE_URL_BASE}/{PROJECT_ID}/regions/europe-west2/subnetworks/{SUBNETWORK}",
                "accessConfigs": [{
                    "name": "External NAT",
                    "networkTier": "PREMIUM",
                    "type": "ONE_TO_ONE_NAT",
                }],
            }]
        }
    }
    return {"resources": [VM]}

在部署过程中,我收到了以下警告:

dineshsonachalam@macbook compute_engine % gcloud deployment-manager deployments create dinesh-vm --template vm.py
The fingerprint of the deployment is b'ZmY2S4OqjswQhQfT_=='
Waiting for create [operation-1684]...done.                                                                       
WARNING: Create operation operation-1674932237 completed with warnings:
---
code: EXTERNAL_API_WARNING
data:
- key: disk_size_gb
  value: '60'
- key: image_size_gb
  value: '10'
message: "Disk size: '60 GB' is larger than image size: '10 GB'. You might need to resize the root repartition manually if the operating system does not support automatic resizing. See https://cloud.google.com/compute/docs/disks/add-persistent-disk#resize_pd for details."

NAME       TYPE                 STATE      ERRORS  INTENT
dinesh-vm  compute.v1.instance  COMPLETED  []
dineshsonachalam@macbook compute_engine %

我想了解这个警告的影响以及如何解决它。任何指导或见解都将不胜感激。谢谢!

编辑:

看起来如果您使用公共镜像,Compute Engine会自动调整引导磁盘的大小。

dineshsonachalam@macbook Desktop % gcloud compute images list | grep -i "debian"
NAME                                                  PROJECT              FAMILY                             DEPRECATED  STATUS
debian-10-buster-v20230510                            debian-cloud         debian-10                                      READY
debian-11-bullseye-v20230509                          debian-cloud         debian-11                                      READY

Disk size is larger than image size when creating Compute Engine VM in Google Cloud Deployment Manager Template

参考链接:https://cloud.google.com/compute/docs/disks/resize-persistent-disk

如果支持自动调整大小,为什么我仍然收到警告?

英文:

I'm using a Google Cloud Deployment Manager Template to create a Compute Engine VM instance in Google Cloud. However, I'm encountering a warning during the deployment process: "Disk size: '60 GB' is larger than image size: '10 GB'." The deployment is completed successfully, but I want to understand the implications of this warning and how to address it.

Here is my Deployment Manager template code:

def generate_config(context):
    COMPUTE_URL_BASE = "https://www.googleapis.com/compute/v1/projects"
    SOURCE_IMAGE=f"{COMPUTE_URL_BASE}/debian-cloud/global/images/family/debian-11"
    DISK_SIZE=60
    
    VM_MACHINE_TYPE = "g1-small"
    REGION = "europe-west2-b"
    PROJECT_ID = context.env["project"]
    VPC_NETWORK="default"
    SUBNETWORK="default"


    VM = {
        "name": "dinesh-vm",
        "type": "compute.v1.instance",
        "properties": {
            "zone": REGION,
            "machineType": f"zones/{REGION}/machineTypes/{VM_MACHINE_TYPE}",
            "disks": [{
                "boot": True,
                "autoDelete": True,
                "initializeParams": {
                    "sourceImage": SOURCE_IMAGE,
                    "diskSizeGb": DISK_SIZE,
                },
            }],
            "networkInterfaces": [{
                "network": f"{COMPUTE_URL_BASE}/{PROJECT_ID}/global/networks/{VPC_NETWORK}",
                "subnetwork": f"{COMPUTE_URL_BASE}/{PROJECT_ID}/regions/europe-west2/subnetworks/{SUBNETWORK}",
                "accessConfigs": [{
                    "name": "External NAT",
                    "networkTier": "PREMIUM",
                    "type": "ONE_TO_ONE_NAT",
                }],
            }]
        }
    }
    return {"resources": [VM]}

During the deployment process, I receive the following warning:

dineshsonachalam@macbook compute_engine % gcloud deployment-manager deployments create dinesh-vm --template vm.py
The fingerprint of the deployment is b'ZmY2S4OqjswQhQfT_=='
Waiting for create [operation-1684]...done.                                                                       
WARNING: Create operation operation-1674932237 completed with warnings:
---
code: EXTERNAL_API_WARNING
data:
- key: disk_size_gb
  value: '60'
- key: image_size_gb
  value: '10'
message: "Disk size: '60 GB' is larger than image size: '10 GB'. You might need to\
  \ resize the root repartition manually if the operating system does not support\
  \ automatic resizing. See https://cloud.google.com/compute/docs/disks/add-persistent-disk#resize_pd\
  \ for details."

NAME       TYPE                 STATE      ERRORS  INTENT
dinesh-vm  compute.v1.instance  COMPLETED  []
dineshsonachalam@macbook compute_engine % 

I would like to understand the implications of this warning and how I can address it.
Any guidance or insights would be greatly appreciated. Thank you!

Edit:

It seems like if you're using a public image, Compute Engine automatically resizes the boot disks.

dineshsonachalam@macbook Desktop % gcloud compute images list | grep -i "debian"
NAME                                                  PROJECT              FAMILY                             DEPRECATED  STATUS
debian-10-buster-v20230510                            debian-cloud         debian-10                                      READY
debian-11-bullseye-v20230509                          debian-cloud         debian-11                                      READY

Disk size is larger than image size when creating Compute Engine VM in Google Cloud Deployment Manager Template
Reference: https://cloud.google.com/compute/docs/disks/resize-persistent-disk

If automatic resizing is supported, why am I still receiving the warning?

答案1

得分: 2

这只是一个警告,您可以根据自己的判断忽略它。如果您在GCP中创建的磁盘大于镜像的大小,可用空间将仅等于镜像的大小。例如,如果您使用GCP中的默认镜像之一创建了一个30GB的磁盘,而该镜像的大小为10GB,则可用空间仍然只有10GB。通过参考这个官方文档1文档2,您可以调整磁盘大小。为了避免这个警告,您可以修改模板以使用磁盘大小>= 200GB

根据@Johnhanley的评论,Debian镜像支持根文件系统的自动调整大小。您可以阅读John Hanley于2018年10月27日发布的博客,了解更多信息。

英文:

This is just a warning and we can ignore it as per your discretion. If you create a disk larger than the size of the image in GCP, the usable space will only be equal to the size of the image. For example, if you create a disk of 30GB using one of the default images in GCP, which has a size of 10GB, the usable space will still only be 10GB. By following this official doc1 and Doc2 you can resize the disk size. To avoid the warning, you can revise your template to use disk size >= 200GB

> As per @Johnhanley comments The Debian images support automatic
> resizing of the root file system. You can Go through the blog By
> John Hanley on October 27th, 2018 in Debian, Google

huangapple
  • 本文由 发表于 2023年5月24日 18:06:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76322354.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定