【问题标题】:How can I deploy VM images from Container Registry using Google Cloud如何使用 Google Cloud 从 Container Registry 部署 VM 映像
【发布时间】:2020-09-11 14:38:33
【问题描述】:

执行命令后,我可以看到我的 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
        }]
    }
}

以及下面的实例创建函数:

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

【问题讨论】:

    标签: docker google-cloud-platform google-compute-engine gcloud google-container-registry


    【解决方案1】:

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

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

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

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2022-01-27
      • 2021-05-31
      • 2022-10-04
      • 2021-12-22
      • 2017-07-02
      • 2020-10-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-29
      相关资源
      最近更新 更多