繁体   English   中英

如何使用 Google Cloud 从 Container Registry 部署 VM 映像

[英]How can I deploy VM images from Container Registry using Google Cloud

我可以看到我的 VM 映像在执行以下命令后在 Google Container Registry 中可用:

docker tag sutechnology/transcode eu.gcr.io/supereye/transcode

docker push eu.gcr.io/supereye/transcode

gcloud auth configure-docker docker push eu.gcr.io/supereye/transcode

虽然我可以看到图像,但在 Google Compute Engine 中创建新实例时,我无法使用此图像。 在创建新的 VM 实例时,如何使用在 Container Registry 中看到的映像? 下面是我的完整配置:

machine_type = "zones/europe-west2-b/machineTypes/n1-standard-1"
disk_type = "zones/europe-west2-b/diskTypes/pd-standard"

config = {
    'name': name,
    'machineType': machine_type,

    # Specify the boot disk and the image to use as a source.
    'disks': [
        {
            'boot': True,
            'autoDelete': True,
            'initializeParams': {
                'sourceImage': source_disk_image,
            }
        }
    ],

    # Specify a network interface with NAT to access the public
    # internet.
    'networkInterfaces': [{
        'network': 'global/networks/default',
        'accessConfigs': [
            {'type': 'ONE_TO_ONE_NAT', 'name': 'External NAT'}
        ]
    }],

    # Allow the instance to access cloud storage and logging.
    'serviceAccounts': [{
        'email': 'default',
        'scopes': [
            'https://www.googleapis.com/auth/devstorage.read_write',
            'https://www.googleapis.com/auth/logging.write'
        ]
    }],

    # Metadata is readable from the instance and allows you to
    # pass configuration from deployment scripts to instances.
    'metadata': {
        'items': [{
            # Startup script is automatically executed by the
            # instance upon startup.
            'key': 'startup-script',
            'value': startup_script,
            'VIDEOPATH': videopath
        }]
    }
}

以及实例创建function如下:

compute.instances().insert(
        project=project,
        zone=zone,
        body=config).execute()

Google Container Registry (GCR),用于存储 docker 图像,然后用于创建容器而不是计算引擎机器。

对于 Compute Engine,请使用现有机器的公共映像或自定义映像快照。

参考:- https://cloud.google.com/container-registry

希望这可以帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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