pulumi / pulumi-google-native

Apache License 2.0
72 stars 18 forks source link

Creation of instance template with container image #227

Open SamyPesse opened 3 years ago

SamyPesse commented 3 years ago

GCP supports creating instance template to deploy docker container: https://cloud.google.com/compute/docs/containers/deploying-containers#managedinstancegroupcontainer / https://cloud.google.com/sdk/gcloud/reference/beta/compute/instance-templates/create-with-container

But it doesn't seem possible to do it with Pulumi at the moment (with native or the classic). Am I missing something?

mikhailshilkov commented 3 years ago

Thank you for your question! It looks like the example you linked uses the beta API of the compute service but, indeed, I don't see any container-related properties in the Discovery Document (the API spec) that Google provides, see here.

I will ask Google folks to check why.

mikhailshilkov commented 3 years ago

@SamyPesse One option to figure out what is going on: if you have a gcloud CLI command that works for you, you could run it with --log-http parameter and see the actual HTTP requests that it issues. If you paste those in this issue, it would be super helpful.

m-strzelczyk commented 3 years ago

Hello! I work with GCP and I can share some insights here.

Unfortunately, creating instances and templates that run containers is currently limited to Cloud Console and gcloud tool only. If you go into Cloud Console, click through the Instance creation page and click "Equivalent REST", you'll see the API request with:

"metadata": {
    "items": [
      {
        "key": "gce-container-declaration",
        "value": "spec:\n  containers:\n  - name: instance-1\n    image: ngingx\n    stdin: false\n    tty: false\n  restartPolicy: Always\n# This container declaration format is not public API and may change without notice. Please\n# use gcloud command-line tool or Google Cloud Console to run Containers on Google Compute Engine."
      }
    ]
  },

Most important is the comment:

This container declaration format is not public API and may change without notice. Please use gcloud command-line tool or Google Cloud Console to run Containers on Google Compute Engine.

As you can see, the way we create instances hosting containers is not fully finalized yet and the way it's done is subject to change. Obviously, with the REST preview, you can reverse engineer how it's done right now, but it's not really recommended.

Let me know if you have any further questions.

simenandre commented 2 years ago

How about we create an experimental Pulumi Package to handle this? We can release this under Pulumiverse, and I would love to contribute to it.

nonylene commented 7 months ago

It would be like https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/latest on Terraform