简体   繁体   English

Compute Engine API - 如何使用容器创建实例?

[英]Compute Engine API - How to create an instance with container?

I'm trying to create a GCE instance "with a container" (as supported by gcloud CLI ) by using POST https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances .我正在尝试使用POST https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/创建一个“带有容器”的 GCE 实例(由gcloud CLI支持) 实例

How can I pass the container image url in the request payload?如何在请求负载中传递容器镜像 url?

If you are trying to set the "Machine Type", then you can specify the URL following the syntax mentioned in this document . 如果尝试设置“机器类型”,则可以按照本文档中提到的语法指定URL。

In document: 在文件中:

Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type. 要用于此实例的计算机类型资源的完整或部分URL,格式为:zone / zone / machineTypes / machine-type。 This is provided by the client when the instance is created. 创建实例时由客户端提供。 For example, the following is a valid partial url to a predefined machine type: 例如,以下是预定义机器类型的有效部分URL:

zones/us-central1-f/machineTypes/n1-standard-1 区域/ us-central1-f / machineTypes / n1-standard-1

To create a custom machine type, provide a URL to a machine type in the following format, where CPUS is 1 or an even number up to 32 (2, 4, 6, ... 24, etc), and MEMORY is the total memory for this instance. 要创建自定义机器类型,请以以下格式提供机器类型的URL,其中CPUS为1或偶数,最大为32(2、4、6,... 24等),而MEMORY为总数此实例的内存。 Memory must be a multiple of 256 MB and must be supplied in MB (eg 5 GB of memory is 5120 MB): 内存必须是256 MB的倍数,并且必须以MB为单位提供(例如5 GB的内存为5120 MB):

zones/zone/machineTypes/custom-CPUS-MEMORY 区域/区域/机器类型/自定义CPUS-MEMORY

For example: zones/us-central1-f/machineTypes/custom-4-5120 For a full list of restrictions, read the Specifications for custom machine types. 例如:zones / us-central1-f / machineTypes / custom-4-5120有关限制的完整列表,请阅读自定义机器类型的规格。

If you instead, you want to create a container cluster, then the API method mentioned in this link can help you. 相反,如果要创建容器集群,那么此链接中提到的API方法可以为您提供帮助。

It doesn't seem that there's an equivalent REST API for gcloud compute instances create-with-container... , however as suggested by @user10880591's comment , Terraform can help.对于gcloud compute instances create-with-container...似乎没有等效的 REST API,但是正如@user10880591 的评论所建议的,Terraform 可以提供帮助。 Specifically, the container-vm module deals with the generation of metadata required for this kind of action.具体来说, container-vm 模块处理此类操作所需的元数据的生成。

Usage example can be found here .可以在此处找到用法示例。

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

相关问题 如何移植谷歌计算引擎实例? - How to port forward Google Compute Engine Instance? 将 DialogFlow 连接到 Compute Engine 实例 - Connect DialogFlow to Compute Engine Instance “冻结”谷歌计算引擎实例 PostgreSQL - "frozen" Google compute engine instance with PostgreSQL gcp 计算实例上的 BigQuery API - BigQuery API on gcp compute instance 从 Compute Engine 实例模板创建 Google Batch 作业,未正确导入自定义 Python 库 - Create a Google Batch Job from a Compute Engine instance template, not importing custom Python libraries correctly 无法创建分配临时外部 IP 的 Compute Engine 实例模板 - Can't create a Compute Engine instance template that assigns ephemeral external IPs 重命名 Google Compute Engine VM 实例 - Rename Google Compute Engine VM Instance 如何在 Google Cloud Compute Engine 实例上轮换临时 IP? - How do I rotate ephemeral IP on Google Cloud Compute Engine instance? 如何配置 Terraform 以在不销毁和重新创建的情况下更新 GCP 计算引擎实例模板? - How can I configure Terraform to update a GCP compute engine instance template without destroying and re-creating? 无法 SSH 进入我在 Google Cloud 上的 Compute Engine 虚拟机实例 - Unable to SSH into my Compute Engine VM instance on Google Cloud
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM