Reputation: 291
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.
How can I pass the container image url in the request payload?
Upvotes: 3
Views: 224
Reputation: 6018
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. Specifically, the container-vm module deals with the generation of metadata required for this kind of action.
Usage example can be found here.
Upvotes: 0
Reputation: 71
If you are trying to set the "Machine Type", then you can specify the URL following the syntax mentioned in this document.
In document:
Full or partial URL of the machine type resource to use for this instance, in the format: zones/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:
zones/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. Memory must be a multiple of 256 MB and must be supplied in MB (e.g. 5 GB of memory is 5120 MB):
zones/zone/machineTypes/custom-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.
If you instead, you want to create a container cluster, then the API method mentioned in this link can help you.
Upvotes: 0